samvyo-js-sdk 2.0.7 → 2.0.9
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/dest/samvyo-js-sdk.js +12 -33
- package/index.js +1 -1
- package/package.json +31 -25
- package/vite.config.js +52 -0
package/dest/samvyo-js-sdk.js
CHANGED
|
@@ -1,35 +1,14 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* samvyo-js-sdk v2.0.6
|
|
3
|
-
* This is the client js sdk for cutting-edge Samvyo real-time voice/video cloud.
|
|
4
|
-
* Copyright: 2017-2025 sauravkp <saurav.codes@gmail.com>
|
|
5
|
-
* License: Unlicensed
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).samvyo=e()}}((function(){var define,module,exports;return function e(t,r,i){function n(s,o){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!o&&c)return c(s,!0);if(a)return a(s,!0);var d=new Error("Cannot find module '"+s+"'");throw d.code="MODULE_NOT_FOUND",d}var u=r[s]={exports:{}};t[s][0].call(u.exports,(function(e){return n(t[s][1][e]||e)}),u,u.exports,e,t,r,i)}return r[s].exports}for(var a="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(e,t,r){"use strict";var i=e("./lib/JsSdk_v1"),n=e("./lib/JsSdk"),a=e("./p2p/lib/P2pSdk");t.exports={JsSdk_v1:i.JsSdk_v1,JsSdk:n.JsSdk,P2pSdk:a.P2pSdk}},{"./lib/JsSdk":2,"./lib/JsSdk_v1":3,"./p2p/lib/P2pSdk":318}],2:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault"),n=e("@babel/runtime/helpers/typeof");Object.defineProperty(r,"__esModule",{value:!0}),r.JsSdk=void 0;var a=i(e("@babel/runtime/helpers/typeof")),s=i(e("@babel/runtime/helpers/objectWithoutProperties")),o=i(e("@babel/runtime/regenerator")),c=i(e("@babel/runtime/helpers/asyncToGenerator")),d=i(e("@babel/runtime/helpers/classCallCheck")),u=i(e("@babel/runtime/helpers/createClass")),l=i(e("@babel/runtime/helpers/possibleConstructorReturn")),h=i(e("@babel/runtime/helpers/getPrototypeOf")),f=i(e("@babel/runtime/helpers/inherits")),p=i(e("@babel/runtime/helpers/defineProperty")),m=D(e("mediasoup-client")),b=i(e("bowser")),g=e("./socket"),v=e("events"),y=i(e("./Logger")),_=e("./utils/queue"),w=e("./utils/sleep"),S=e("./utils/getRandomInt"),k=e("./utils/uuidv4"),R=(e("./utils/getVidScaleUrl"),e("./utils/verifyOutputQualites")),P=i(e("./utils/randomName")),M=e("./utils/chooseMedia"),E=D(e("jsonwebtoken")),x=(e("./utils/getUSerMediaConstraints"),e("./utils/constants")),T=e("./utils/verifyfileTypes"),C=["senderPeerId","mediaTag","sender","audioStatus","videoStatus","senderParticipantType","type","producerPaused"];function I(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(I=function(e){return e?r:t})(e)}function D(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=n(e)&&"function"!=typeof e)return{default:e};var r=I(t);if(r&&r.has(e))return r.get(e);var i={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&{}.hasOwnProperty.call(e,s)){var o=a?Object.getOwnPropertyDescriptor(e,s):null;o&&(o.get||o.set)?Object.defineProperty(i,s,o):i[s]=e[s]}return i.default=e,r&&r.set(e,i),i}function O(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return A(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?A(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function L(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 j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?L(Object(r),!0).forEach((function(t){(0,p.default)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function B(e,t,r){return t=(0,h.default)(t),(0,l.default)(e,N()?Reflect.construct(t,r||[],(0,h.default)(e).constructor):t.apply(e,r))}function N(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(N=function(){return!!e})()}var F,U=new y.default("Room"),q={small:{width:{ideal:160},height:{ideal:120}},qvga:{width:{ideal:320},height:{ideal:240}},vga:{width:{ideal:640},height:{ideal:480}},hd:{width:{ideal:1280},height:{ideal:720}}},z=new _.SocketQueue;r.JsSdk=function(e){function t(e){var r,i=e.peerId,n=e.roomId,a=e.outputData;return(0,d.default)(this,t),r=B(this,t),(0,p.default)(r,"joinRoom",(0,c.default)(o.default.mark((function e(){var t,i,n,a,s,c,d,u,l,h,f,p,m,b,g,v,y,_,w,S,k,R,M,E,T,C,I,D,O,A,L,B,N,F,q,z,V,G,W,H,K,$,J,Y,X,Z,Q,ee,te,re,ie,ne,ae,se,oe,ce,de,ue,le,he,fe,pe,me,be,ge,ve,ye=arguments;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=(t=ye.length>0&&void 0!==ye[0]?ye[0]:{}).peerName,n=void 0===i?null:i,a=t.produce,s=void 0===a||a,c=t.produceAudio,d=void 0===c||c,u=t.produceVideo,l=void 0===u||u,h=t.consume,f=void 0===h||h,p=t.videoResolution,m=void 0===p?"hd":p,b=t.forceVp8,g=void 0!==b&&b,v=t.forceVp9,y=void 0!==v&&v,_=t.forceH264,w=void 0!==_&&_,S=t.h264Profile,k=void 0===S?"high":S,R=t.forcePCMU,M=void 0!==R&&R,E=t.forcePCMA,T=void 0!==E&&E,C=t.forceFPS,I=void 0===C?25:C,D=t.enableWebcamLayers,O=void 0===D||D,A=t.numSimulcastStreams,L=void 0===A?3:A,B=t.autoGainControl,N=void 0===B||B,F=t.echoCancellation,q=void 0===F||F,z=t.noiseSuppression,V=void 0===z||z,G=t.sampleRate,W=void 0===G?44e3:G,H=t.channelCount,K=void 0===H?1:H,$=t.videoBitRates,J=void 0===$?[700,250,75]:$,Y=t.share,X=void 0!==Y&&Y,Z=t.shareAudio,Q=void 0!==Z&&Z,ee=t.enableSharingLayers,te=void 0===ee||ee,re=t.shareBitRates,ie=void 0===re?[2500,1250,500]:re,ne=t.audioDeviceId,ae=void 0===ne?null:ne,se=t.videoDeviceId,oe=void 0===se?null:se,ce=t.peerType,de=void 0===ce?"participant":ce,ue=t.roomType,le=void 0===ue?x._security.roomType.CONFERENCING:ue,he=t.authenticationRequired,fe=void 0!==he&&he,pe=t.password,me=void 0===pe?null:pe,be=t.roomDisplayName,ge=void 0===be?null:be,U.info("Going to join room"),["hd","vga","qvga"].includes(m)||(U.warn("Invalid video resolution value. setting it to default value of 'hd' "),m="hd"),"boolean"!=typeof s&&(U.warn("Produe should either be true or false"),s=Boolean(s)),"boolean"!=typeof d&&(U.warn("ProduceAudio should either be true or false"),d=Boolean(d)),"boolean"!=typeof l&&(U.warn("ProduceVideo should either be true or false"),l=Boolean(l)),"boolean"!=typeof f&&(U.warn("Consume should either be true or false"),f=Boolean(f)),"boolean"!=typeof g&&(U.warn("forceVp8 should either be true or false"),g=Boolean(g)),"boolean"!=typeof y&&(U.warn("forceVp9 should either be true or false"),y=Boolean(y)),"boolean"!=typeof w&&(U.warn("forceH264 should either be true or false"),w=Boolean(w)),["high","low"].includes(k.toLowerCase())||(U.warn("h264Profile should either be 'high' or 'low'"),k="high"),(!Number.isInteger(I)||Number.isInteger(I)&&(I>65||I<5))&&(U.warn("forceFPS should be a number between 5 to 65, default value is 25 fps."),I=25),"boolean"!=typeof O&&(U.warn("enableWebcamLayers should either be true or false"),O=Boolean(O)),(!Number.isInteger(L)||Number.isInteger(L)&&(L>3||L<1))&&(U.warn("numSimulcastStreams should be a number between 1 to 3, default value is 3."),L=3),Array.isArray(J)&&J.length>=1&&J.length<=3&&J.every((function(e){return Number.isInteger(e)&&e>=75&&e<=800}))?U.debug("videoBitRates values are correct"):(U.warn("videobitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[700,250,75]'"),J=[700,250,75]),"boolean"!=typeof M&&(U.warn("forcePCMU should either be true or false"),M=Boolean(M)),"boolean"!=typeof T&&(U.warn("forcePCMA should either be true or false"),T=Boolean(T)),"boolean"!=typeof N&&(U.warn("autoGainControl should either be true or false"),N=Boolean(N)),"boolean"!=typeof q&&(U.warn("echoCancellation should either be true or false"),q=Boolean(q)),"boolean"!=typeof V&&(U.warn("noiseSuppression should either be true or false"),V=Boolean(V)),(!Number.isInteger(W)||Number.isInteger(W)&&(W>64e3||W<8e3))&&(U.warn("sampleRate should be a number between 8000 to 64000, default value is 44000 Khz."),W=44e3),(!Number.isInteger(K)||Number.isInteger(K)&&(K>2||K<1))&&(U.warn("sampleRate should be a number between 1 to 2, default value is 1, which is a mono audio."),K=1),"boolean"!=typeof X&&(U.warn("share should either be true or false"),X=Boolean(X)),"boolean"!=typeof Q&&(U.warn("shareAudio should either be true or false"),Q=Boolean(Q)),"boolean"!=typeof te&&(U.warn("enableSharingLayers should either be true or false"),te=Boolean(te)),Array.isArray(ie)&&ie.length>=1&&ie.length<=3&&ie.every((function(e){return Number.isInteger(e)&&e>=500&&e<=2500}))?U.debug("shareBitRates values are correct"):(U.warn("sharebitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[2500,1250,500]'"),ie=[2500,1250,500]),["moderator","participant","attendee"].includes(de)?U.debug("peerType is valid:%s",de):(de="participant",U.debug("peerType is invalid:%s. By default set to: participant",de)),e.next=29,r.listDevicesInternal();case 29:r._videoResolution=m,r._forceVP8=Boolean(g),r._forceH264=Boolean(w),r._forceVP9=Boolean(y),r._enableWebcamLayers=Boolean(O),r._numSimulcastStreams=L,r._enableSharingLayers=Boolean(te),e.prev=36,n||(n=(0,P.default)()),r.data.inputParams=j(j({},r.data.inputParams),{},{peerName:n,produce:s,produceAudio:d,produceVideo:l,consume:f,videoResolution:m,forceVp8:g,forceVp9:y,forceH264:w,h264Profile:k,forceFPS:I,forcePCMU:M,forcePCMA:T,enableWebcamLayers:O,numSimulcastStreams:L,autoGainControl:N,echoCancellation:q,noiseSuppression:V,sampleRate:W,channelCount:K,videoBitRates:J,share:X,shareAudio:Q,enableSharingLayers:te,shareBitRates:ie,audioDeviceId:ae,videoDeviceId:oe,peerType:de,roomType:le,authenticationRequired:fe,password:me,roomDisplayName:ge}),U.info("input params are:%O",r.data.inputParams),ve={id:"joinRoom",type:"r",peerId:r.data.inputParams.peerId,participantType:"attendee"===de?"viewer":de,roomType:le,roomDisplayName:ge||"room-".concat(1e5+Math.round(9e5*Math.random())),browser:r._client,name:r.data.inputParams.peerName,room:r.data.inputParams.roomId,authenticationRequired:fe,isRoomPassword:!!me,roomPassword:me||null,usageType:"sdk"},r._sendMessage(ve),e.next=48;break;case 44:return e.prev=44,e.t0=e.catch(36),U.error("Failed to join room:",e.t0.message),e.abrupt("return",{success:!1,reason:e.t0.message});case 48:case"end":return e.stop()}}),e,null,[[36,44]])})))),(0,p.default)(r,"authenticateUser",(function(e){U.info("Moderator authentication requested:%O",e),r.emit("moderatorAuthentication",{moderatorName:e.moderatorName,requesterName:e.requesterName,requesterPeerId:e.requesterPeerId,text:e.title})})),(0,p.default)(r,"authenticationRequested",(function(e){U.info("Moderator authentication requested:%O",e),r.emit("authenticationRequested",{requesterName:e.requesterName,requesterPeerId:r.data.inputParams.peerId,text:e.title})})),(0,p.default)(r,"allowRoomJoin",(function(e){if(!e)return U.error("peerId can't be undefined!"),{success:!1,reason:"PeerId can't be undefined"};U.info("Allow user to join room:%O",e);var t={id:"userAuthenticated",peerId:e,roomName:r.data.inputParams.roomId,moderator:r.data.inputParams.peerId};r._sendMessage(t)})),(0,p.default)(r,"denyRoomJoin",(function(e){if(!e)return U.error("peerId can't be undefined!"),{success:!1,reason:"PeerId can't be undefined"};U.info("Deny user to join room:%O",e);var t={id:"userDenied",peerId:e,roomName:r.data.inputParams.roomId,moderator:r.data.inputParams.peerId};r._sendMessage(t)})),(0,p.default)(r,"hideUserAuthenticationDialog",(function(e){U.debug("authentication already done message:%o",e),r.emit("moderatorAuthStatus",{requesterId:e.requesterId,moderatorActed:e.peerId})})),(0,p.default)(r,"sendCustomMessage",(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"general",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},o={id:"customMessage",peerId:r.data.inputParams.peerId,roomName:r.data.inputParams.roomId,data:e,type:t,recieverPeerId:i,senderType:n,messageType:a,customData:s};U.debug("Room sendCustomMessage",o),r._sendMessage(o)})),(0,p.default)(r,"processCustomMessage",(function(e){U.debug("Room processCustomMessage",e),r.emit("customMessage",e)})),(0,p.default)(r,"updateCId",(function(e){U.debug("Received updateCId message",e),e.targetPeerId!==r.data.inputParams.peerId&&e.targetPeerId||r.emit("updateCId",{message:e,cId:e.cId,peerId:r.data.inputParams.peerId,isMyCId:e.targetPeerId===r.data.inputParams.peerId})})),(0,p.default)(r,"_createSendTransport",(0,c.default)(o.default.mark((function e(){var t;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U.debug("Room _createSendTransport"),e.prev=1,r._device.loaded){e.next=6;break}return U.debug("Room _createSendTransport","Going to load device with routerrtpcapabilities"),e.next=6,r._device.load({routerRtpCapabilities:r._routerRtpCapabilities});case 6:t=x.MSG_DIRECTION_SEND,r._sendTransport||r._sendMessage({id:"createTransport",peerId:r.data.inputParams.peerId,roomName:r.data.inputParams.roomId,direction:t}),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(1),U.error("Room _createSendTransport",e.t0);case 13:case"end":return e.stop()}}),e,null,[[1,10]])})))),(0,p.default)(r,"_createRecvTransport",(0,c.default)(o.default.mark((function e(){var t;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r._device.loaded){e.next=4;break}return U.debug("loading device for creating recv transport"),e.next=4,r._device.load({routerRtpCapabilities:r._routerRtpCapabilities});case 4:t=x.MSG_DIRECTION_RECV,r._recvTransport||(U.debug("receive transport created"),r._sendMessage({id:"createTransport",peerId:r.data.inputParams.peerId,roomName:r.data.inputParams.roomId,direction:t}));case 6:case"end":return e.stop()}}),e)})))),(0,p.default)(r,"handleCreateTransportRequest",function(){var e=(0,c.default)(o.default.mark((function e(t){var i,n,a;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U.debug("Room handleCreateTransportRequest():%O",t),i=t.transportOptions,n=t.direction,a=void 0,e.prev=3,"recv"!==n){e.next=13;break}return e.next=7,r._device.createRecvTransport(i);case 7:a=e.sent,U.debug("Room","handleCreateTransportRequest() recv transport created ".concat(a.id)),r._recvTransport=a,r.handleRecvTransportListeners(),e.next=24;break;case 13:if("send"!==n){e.next=23;break}return e.next=16,r._device.createSendTransport(i);case 16:a=e.sent,U.debug("Room","handleCreateTransportRequest() send transport created [id:%s]".concat(a.id)),r._sendTransport=a,r.handleSendTransportListeners(),r.produceMedia(),e.next=24;break;case 23:throw new Error("bad transport 'direction': ".concat(n));case 24:e.next=29;break;case 26:e.prev=26,e.t0=e.catch(3),console.error("handleCreateTransportRequest() failed to create transport [error:%o]",e.t0);case 29:case"end":return e.stop()}}),e,null,[[3,26]])})));return function(t){return e.apply(this,arguments)}}()),(0,p.default)(r,"handleSendTransportListeners",(function(){r._sendTransport.on("connect",r.handleTransportConnectEvent),r._sendTransport.on("produce",r.handleTransportProduceEvent);var e=r;r._sendTransport.on("connectionstatechange",function(){var t=(0,c.default)(o.default.mark((function t(i){return o.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(U.debug("ConferenceRoom sendTransport connectionState ".concat(i," & socketconnection state ").concat(r._socket._ws.readyState)),"failed"!==i&&"disconnected"!==i){t.next=13;break}if(1!==r._socket._ws.readyState){t.next=6;break}e.restartIce(r._sendTransport.id,"send"),t.next=13;break;case 6:if(1===r._socket._ws.readyState){t.next=12;break}return U.debug("socket not yet ready with state- ".concat(r._socket._ws.readyState)),t.next=10,(0,w.sleep)(1500);case 10:t.next=6;break;case 12:"connected"===r._roomStatus&&r.restartIce(r._sendTransport.id,"send");case 13:U.debug("ConferenceRoom","send transport connection state change [state:%s]".concat(i));case 14:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())})),(0,p.default)(r,"handleTransportConnectEvent",(function(e,t,i){var n=e.dtlsParameters;try{z.push("connectTransport",(function(e){U.debug("connect-transport action"),t(),z.remove("connectTransport")}));var a={id:"connectTransport",peerId:r.data.inputParams.peerId,roomName:r.data.inputParams.roomId,transportId:r._sendTransport.id,dtlsParameters:n,direction:"send"};r._sendMessage(a)}catch(e){U.error("handleTransportConnectEvent() failed [error:%o]",e),i(e)}})),(0,p.default)(r,"handleTransportProduceEvent",(function(e,t,i){var n=e.kind,a=e.rtpParameters,s=e.appData;try{z.push("produce",(function(e){U.debug("handleTransportProduceEvent callback [data:%o]",e),t({id:e.producerId}),z.remove("produce")}));var o=s.mediaTag===x.STREAM_TYPE_CAM_AUDIO&&void 0!==r.data.inputParams.audioStatus&&!r.data.inputParams.audioStatus;U.debug("handleTransportProduceEvent() | pause status->".concat(o));var c={id:"sendTrack",transportId:r._sendTransport.id,peerId:r.data.inputParams.peerId,roomName:r.data.inputParams.roomId,kind:n,rtpParameters:a,paused:o,appData:s,clientOs:r._client.os.name,browser:r._client.browser};r._sendMessage(c)}catch(e){U.error("handleTransportProduceEvent() failed [error:%o]",e),i(e)}})),(0,p.default)(r,"produceMedia",(0,c.default)(o.default.mark((function e(){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.data.inputParams.produce?(r.data.inputParams.produceAudio?r.enableMic({deviceId:r.data.inputParams.audioDeviceId?r.data.inputParams.audioDeviceId:null}):U.debug("No need to produce audio!"),r._device.canProduce("video")&&(r.data.inputParams.produceVideo?r.enableCam({deviceId:r.data.inputParams.videoDeviceId?r.data.inputParams.videoDeviceId:null}):U.debug("No need to produce video!"),r.data.inputParams.share&&r.enableShare({shareAudio:r.data.inputParams.shareAudio,enableSharingLayers:r._enableSharingLayers,shareBitRates:r.data.inputParams.shareBitRates}))):U.warn("produce is false!");case 1:case"end":return e.stop()}}),e)})))),(0,p.default)(r,"handleRecvTransportListeners",(0,c.default)(o.default.mark((function e(){var t,i;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r._recvTransport.on("connect",r.handleRecvTransportConnectEvent),t=r,r._recvTransport.on("connectionstatechange",function(){var e=(0,c.default)(o.default.mark((function e(i){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U.debug("ConferenceRoom recvTransport connectionState ".concat(i," & socketconnection state ").concat(r._socket._ws.readyState)),"failed"!==i&&"disconnected"!==i){e.next=13;break}if(1!==r._socket._ws.readyState){e.next=6;break}t.restartIce(r._recvTransport.id,"recv"),e.next=13;break;case 6:if(1===r._socket._ws.readyState){e.next=12;break}return U.debug("socket not yet ready with state- ".concat(r._socket._ws.readyState)),e.next=10,(0,w.sleep)(1e3);case 10:e.next=6;break;case 12:"connected"===r._roomStatus&&t.restartIce(r._recvTransport.id,"recv");case 13:U.debug("ConferenceRoom","Recv transport connection state change [state:%s]".concat(i));case 14:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),i={id:"transportsAvailable",peerId:r.data.inputParams.peerId,roomName:r.data.inputParams.roomId,rtpCapabilities:r._device.rtpCapabilities},r._sendMessage(i);case 5:case"end":return e.stop()}}),e)})))),(0,p.default)(r,"handleRecvTransportConnectEvent",(function(e,t,i){var n=e.dtlsParameters;try{z.push("connectRecvTransport",(function(e){U.debug("ConferenceRoom","connect-recv-transport action"),t(),z.remove("connectRecvTransport")}));var a={id:"connectTransport",peerId:r.data.inputParams.peerId,roomName:r.data.inputParams.roomId,transportId:r._recvTransport.id,dtlsParameters:n,direction:"recv"};r._sendMessage(a)}catch(e){U.error("handleTransportConnectEvent() failed [error:%o]",e),i(e)}})),(0,p.default)(r,"handleRecvTrackRequest",function(){var e=(0,c.default)(o.default.mark((function e(t){var i,n,a,c,d,u,l,h,f,b;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U.debug("Room handleRecvTrackRequest",t),r.data.inputParams.consume){e.next=4;break}return U.warn("I do not want to consume"),e.abrupt("return");case 4:return i=t.senderPeerId,n=t.mediaTag,t.sender,t.audioStatus,t.videoStatus,t.senderParticipantType,a=t.type,c=t.producerPaused,d=(0,s.default)(t,C),U.debug("New consumer created",d),d.id=d.consumerId,delete d.consumerId,U.debug("ConferenceRoom","senderPeerId is ->".concat(i)),e.next=11,r._recvTransport.consume(j(j({},d),{},{streamId:"".concat(i,"-").concat("screen-video"===n||"screen-audio"===n?"share":"mic-webcam"),appData:{peerId:i,mediaTag:n}}));case 11:u=e.sent;case 12:if(!r._recvTransport||"connected"===r._recvTransport.connectionState){e.next=18;break}return U.debug("recv transport connstate".concat(r._recvTransport.connectionState)),e.next=16,(0,w.sleep)(100);case 16:e.next=12;break;case 18:return r._consumers.set(u.id,u),u.on("transportclose",(function(){r._consumers.delete(u.id)})),l=m.parseScalabilityMode(u.rtpParameters.encodings[0].scalabilityMode),h=l.spatialLayers,f=l.temporalLayers,b=r._peers.get(r.data.inputParams.peerId),U.debug("Consumer created for sender peerId ".concat(i," for kind ").concat(u.kind," for receiver peerId ").concat(r.data.inputParams.peerId)),U.info("The old peer data is :%O",b),b?(b["screen-video"===n||"screen-audio"===n?"ss".concat(u.kind):u.kind]={consumerId:u.id,type:a,locallyPaused:!1,remotelyPaused:c,rtpParameters:u.rtpParameters,spatialLayers:h,temporalLayers:f,preferredSpatialLayer:h-1,preferredTemporalLayer:f-1,priority:1,codec:u.rtpParameters.codecs[0].mimeType.split("/")[1],track:u.track,share:"screen-video"===n||"screen-audio"===n},U.info("The new peer data is :%O",b),r._peers.set(r.data.inputParams.peerId,b)):(U.info("Peer not found!"),r._peers.set(r.data.inputParams.peerId,(0,p.default)({},"screen-video"===n||"screen-audio"===n?"ss".concat(u.kind):u.kind,{consumerId:u.id,type:a,locallyPaused:!1,remotelyPaused:c,rtpParameters:u.rtpParameters,spatialLayers:h,temporalLayers:f,preferredSpatialLayer:h-1,preferredTemporalLayer:f-1,priority:1,codec:u.rtpParameters.codecs[0].mimeType.split("/")[1],track:u.track,share:"screen-video"===n||"screen-audio"===n}))),e.next=27,r.resumeConsumer(u);case 27:U.debug("Going to emit mic start / videostart"),"audio"===u.kind?"screen-audio"===n?r.emit("ssAudioStart",{peerId:i,audioTrack:u.track,type:"remote"}):r.emit("micStart",{peerId:i,audioTrack:u.track,type:"remote"}):"video"===u.kind&&("screen-video"===n?r.emit("ssVideoStart",{peerId:i,videoTrack:u.track,type:"remote"}):r.emit("videoStart",{peerId:i,videoTrack:u.track,type:"remote"}));case 29:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),(0,p.default)(r,"resumeConsumer",function(){var e=(0,c.default)(o.default.mark((function e(t){var i;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=12;break}return U.debug("resume consumer",t.appData.peerId,t.appData.mediaTag),e.prev=2,i={id:"resumeConsumer",peerId:r.data.inputParams.peerId,roomName:r.data.inputParams.roomId,consumerId:t.id},r._sendMessage(i),e.next=7,t.resume();case 7:e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),console.error(e.t0);case 12:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(t){return e.apply(this,arguments)}}()),(0,p.default)(r,"handleConnectTransportRequest",function(){var e=(0,c.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U.debug("handleTransportConnectRequest()"),e.prev=1,r=z.get("connectTransport")){e.next=5;break}throw new Error("transport-connect action was not found");case 5:return e.next=7,r(t);case 7:e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),console.error("handleTransportConnectRequest() failed [error:%o]",e.t0);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t){return e.apply(this,arguments)}}()),(0,p.default)(r,"handleConnectRecvTransportRequest",function(){var e=(0,c.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U.debug("handleTransportConnectRequest()"),e.prev=1,r=z.get("connectRecvTransport")){e.next=5;break}throw new Error("recv transport-connect action was not found");case 5:return e.next=7,r(t);case 7:e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),console.error("handleRecvTransportConnectRequest() failed [error:%o]",e.t0);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t){return e.apply(this,arguments)}}()),(0,p.default)(r,"handleSendTrackRequest",function(){var e=(0,c.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U.debug("ConferenceRoom","handleProduceRequest()"),e.prev=1,r=z.get("produce")){e.next=5;break}throw new Error("produce action was not found");case 5:return e.next=7,r(t);case 7:e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),U.error("handleProduceRequest() failed [error:%o]",e.t0);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t){return e.apply(this,arguments)}}()),(0,p.default)(r,"mediaToggled",(function(e){switch(U.debug("Media Toggled message:%O",e),e.type){case"video":U.debug("mediaToggled() | inside case video".concat(e.videoStatus));break;case"audio":U.debug("mediaToggled() | inside case audio".concat(e.videoStatus)),e.audioStatus?r.emit("peerUnMuted",{peerId:e.peerId,type:"remote"}):r.emit("peerMuted",{peerId:e.peerId,type:"remote"})}})),(0,p.default)(r,"closeConsumer",(function(e){var t=e.consumerId,i=r._consumers.get(t);if(i){var n=i.appData,a=n.peerId,s=n.mediaTag;U.debug("Consumer closed for consumerId:%s, type:%s, appData:%o",t,null==i?void 0:i.kind,i.appData);var o="screen-audio"===s||"screen-video"===s?"ss".concat(i.kind):i.kind;i.close(),r._consumers.delete(t);var c=r._peers.get(r.data.inputParams.peerId);U.debug("Peer data before deletion:%O",c),c[o]&&c[o].consumerId===t&&delete c[o],U.debug("Peer data after deletion:%O",c),r._peers.set(r.data.inputParams.peerId,c),"audio"===(null==i?void 0:i.kind)?(U.debug("Going to emit micEnd, consumer closed for audio"),"screen-audio"===s?r.emit("ssAudioStop",{peerId:a,track:null,type:"remote"}):r.emit("micEnd",{peerId:a,track:null,type:"remote"})):"video"===(null==i?void 0:i.kind)&&(U.debug("Going to emit videoEnd, consumer closed for video"),"screen-video"===s?r.emit("ssVideoStop",{peerId:a,track:null,type:"remote"}):r.emit("videoEnd",{peerId:a,track:null,type:"remote"}))}else U.warn("Consumer with id not found!:%s",t)})),(0,p.default)(r,"peerLeft",(function(e){U.debug("Peer Left message is:%o",e);var t=e.peerId;r._peers.delete(t),r.emit("peerLeft",{peerId:t})})),(0,p.default)(r,"roomClosed",(function(){U.info("room closed by Moderator"),r._peers=null,r.emit("roomClosed",{roomId:r.data.inputParams.roomId})})),(0,p.default)(r,"leaveRoomCommon",(function(){r._sendTransport&&(r._sendTransport.close(),r._sendTransport=null),r._recvTransport&&(r._recvTransport.close(),r._recvTransport=null),r._webCamStream&&r._webCamStream.getVideoTracks().forEach((function(e){e.stop(),U.debug("Video Track stopped")})),r._micStream&&r._micStream.getAudioTracks().forEach((function(e){e.stop(),U.debug("Mic Track stopped")})),r._roomStatus="closed",r._running=!1,r._routerRtpCapabilities=null})),(0,p.default)(r,"restartIce",function(){var e=(0,c.default)(o.default.mark((function e(t,i){var n;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!("send"===i&&"connected"===r._sendTransport.connectionState||"recv"===i&&"connected"===r._recvTransport.connectionState)){e.next=3;break}return U.debug("no need to restart ICE as transport now connected"),e.abrupt("return");case 3:U.debug("websocket is ready and connectionstate is still disconnected, therefore going to restart ICE"),n={id:"restartIce",transportId:t,roomName:r.data.inputParams.roomId,peerId:r.data.inputParams.peerId},r._sendMessage(n);case 6:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()),(0,p.default)(r,"restartIceResponse",(function(e){U.debug("restart ICE response:%o",e);var t=e.transportId,i=e.iceParameters;r._sendTransport&&r._sendTransport.id===t?r._sendTransport.restartIce({iceParameters:i}):r._recvTransport&&r._recvTransport.id===t&&r._recvTransport.restartIce({iceParameters:i})})),(0,p.default)(r,"startRecording",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.recordingType,i=void 0===t?null:t,n=e.outputType,a=void 0===n?null:n,s=e.outputQualities,o=void 0===s?null:s;U.debug("recording type requested is:%s,outputType:%s, outputQualties:%o",i,a,o);var c=!i||"av"!==(null==i?void 0:i.toLowerCase())&&"audiovideo"!==(null==i?void 0:i.toLowerCase())?x.MERGEA:x.MERGE;if((!a||"hls"!==a.toLowerCase()&&"mp4"!==a.toLowerCase())&&a)return U.error("Invalid outut type"),{success:!1,reason:"Invalid outputType: ".concat(a,". ")};if(a&&"hls"===a.toLowerCase()&&o&&!(0,R.isValidOutputQualities)(o))return U.error("Invalid outut qualities"),{success:!1,reason:"Invalid outputQualities: ".concat(JSON.stringify(o),". ")+"Allowed values are ".concat(Array.from(R.ALLOWED_QUALITIES).join(", "),".")};var d={id:"startRecording",peerId:r.data.inputParams.peerId,roomName:r.data.inputParams.roomId,url:window.location.hostname,type:x.RECORD,recordingStrategy:c,outputQualities:o,outputType:null==a?void 0:a.toLowerCase()};r._sendMessage(d),r._recordingStartedByMe=j(j({},r._recordingStartedByMe),{},{"main-room":{recordingNo:null}})})),(0,p.default)(r,"stopRecording",(function(){U.debug("going to stop recording for recordingStartedByMe:%o",r._recordingStartedByMe);var e="main-room";if(!r._recordingStartedByMe[e])return{success:!1,error:!0,code:"RRID001",text:"Error while trying to stop recording. Either the recording has not been started yet Or The same user need to stop recording who started it."};var t={id:"stopRecording",peerId:r.data.inputParams.peerId,roomName:r.data.inputParams.roomId,recordingNo:r._recordingStartedByMe[e].recordingNo,type:x.RECORD};r._sendMessage(t),delete r._recordingStartedByMe[e],r.emit("recordingEnded",{peerId:r.data.inputParams.peerId})})),(0,p.default)(r,"setRecordingStatusStarted",(function(e){U.debug("Recording/Streaming started by moderator!!:%O",e);e.breakOutRoom;var t=e.recordingStartTime,i=e.recordingNo,n=e.type;[x.RECORD,x.RTMPSTREAMANDRECORD].includes(n)&&(r._recordingStartedByMe["main-room"]?(U.debug("This recording has been started by me."),r._recordingStartedByMe["main-room"].recordingNo=i,r.emit("recordingStarted",{peerId:r.data.inputParams.peerId,startTime:t})):r.emit("recordingStarted",{startTime:t}))})),(0,p.default)(r,"setRecordingStatusEnded",(function(e){U.debug("Recording ended by moderator!!, data:%O",e);e.breakOutRoom;e.type===x.RTMPSTREAM||r.emit("recordingEnded",{})})),(0,p.default)(r,"startProcessing",(0,c.default)(o.default.mark((function e(){var t,i,n,a,s,c,d,u,l,h,f,m,b,g,v,y,_,w,S,k=arguments;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=(t=k.length>0&&void 0!==k[0]?k[0]:{}).inputFiles,n=void 0===i?[]:i,a=t.outputQualities,s=void 0===a?null:a,c=t.bucket,d=void 0===c?null:c,u=t.cloud,l=void 0===u?null:u,h=t.region,f=void 0===h?null:h,U.debug("Processing of Files requested for:%o",n),m=Math.round(1e7*Math.random()),e.next=5,(0,T.verifyFiles)(n);case 5:if(!(b=e.sent).success){e.next=18;break}if(!s||(0,R.isValidOutputQualities)(s)){e.next=10;break}return U.error("Invalid outut qualities"),e.abrupt("return",{success:!1,reason:"Invalid outputQualities: ".concat(JSON.stringify(s),". ")+"Allowed values are ".concat(Array.from(R.ALLOWED_QUALITIES).join(", "),".")});case 10:r._processingStartedByMe=j(j({},r._processingStartedByMe),{},(0,p.default)({},m,{})),g=O(n);try{for(g.s();!(v=g.n()).done;)y=v.value,_=y.type,w=y.url,r._processingStartedByMe=j(j({},r._processingStartedByMe),{},(0,p.default)({},m,j(j({},r._processingStartedByMe[m]),{},(0,p.default)({},w,{type:_,url:w,status:"pending"}))))}catch(e){g.e(e)}finally{g.f()}return S={id:"processVideos",peerId:r.data.inputParams.peerId,roomName:r.data.inputParams.roomId,inputFiles:n,outputQualities:s,bucket:d,cloud:l,region:f,requestId:m,type:x.PROCESS},r._sendMessage(S),e.abrupt("return",{success:!0});case 18:return e.abrupt("return",b);case 19:case"end":return e.stop()}}),e)})))),(0,p.default)(r,"checkProcessingStatus",(function(e){var t=e.requestId;return U.debug("Going to check processing status for request Id:%s",t),r._processingStartedByMe[t]?{success:!0,details:r._processingStartedByMe[t]}:{success:!0,details:r._processingStartedByMe}})),(0,p.default)(r,"handleProcessingStart",(function(e){var t=e.processingStartTime,i=(e.processingNo,e.requestId);U.debug("handleProcessingStart()| received message is:%o",e),r.emit("processingStarted",{processingStartTime:t,requestId:i})})),(0,p.default)(r,"handleProcessingCompletion",(function(e){var t=e.totalProcessingTime,i=e.hlsfileKey,n=e.size,a=e.originalFile,s=e.lastFile,o=e.requestId;if(U.debug("handleProcessingCompletion()| received message is:%o",e),U.debug("Before update, Total files to be processed are:%o",r._processingStartedByMe),r._processingStartedByMe[a]&&(r._processingStartedByMe=j(j({},r._processingStartedByMe),{},(0,p.default)({},o,j(j({},r._processingStartedByMe[o]),{},(0,p.default)({},a,j(j({},r._processingStartedByMe[a]),{},{status:"completed",hlsfileKey:i,size:n,totalProcessingTime:t})))))),U.debug("After update, Total files to be processed are:%o",r._processingStartedByMe),r.emit("processingCompleted",e),s){U.debug("The last file processing has been completed! Remove all the files that has been completed with the same requesterId");var c=j({},r._processingStartedByMe);delete c[o],U.debug("After deleting the current requestId:%o",c),r._processingStartedByMe=c}})),(0,p.default)(r,"handleProcessingError",(function(e){var t=e.totalProcessingTime,i=e.hlsfileKey,n=e.size,a=e.originalFile,s=(e.lastFile,e.requestId),o=e.error;U.debug("handleProcessingCompletion()| received message is:%o",e),U.debug("Before update, Total files to be processed are:%o",r._processingStartedByMe),r._processingStartedByMe[a]&&(r._processingStartedByMe=j(j({},r._processingStartedByMe),{},(0,p.default)({},s,j(j({},r._processingStartedByMe[s]),{},(0,p.default)({},a,j(j({},r._processingStartedByMe[a]),{},{status:"error",hlsfileKey:i,size:n,totalProcessingTime:t,error:o})))))),U.debug("After update, Total files to be processed are:%o",r._processingStartedByMe),r.emit("processingError",e)})),r._closed=!1,r._roomStatus="initialised",r._roomDisplayName=null,r._running=!1,r._cignal=null,r._socket=null,r._sendTransport=null,r._recvTransport=null,r._device=new m.Device,r._webCamProducer=null,r._micProducer=null,r._shareProducer=null,r._shareAudioProducer=null,r._producers=new Map,r._consumers=new Map,r._peers=new Map,r._data=j(j({},a),{},{inputParams:{peerId:i,roomId:n,roomType:"conferencing"}}),r._micStream=null,r._webCamStream=null,r._webcam={device:null,resolution:"hd"},r._mic={device:null},r._deviceList=F||null,r._externalVideo=null,r._externalVideoStream=null,r._forceVP8=!1,r._forceH264=!1,r._forceVP9=!1,r._enableWebcamLayers=!0,r._numSimulcastStreams=3,r._enableSharingLayers=!0,r._client=b.default.parse(window.navigator.userAgent),r._routerRtpCapabilities=null,r._recordingStartedByMe={},r._cignalConnected=!1,r._reconnectionInitiated=!1,r._restartIceInProgressSendTransport=!1,r._restartIceInProgressRecvTransport=!1,r._activeSpeaker=null,r.initLocal(),r}return(0,f.default)(t,e),(0,u.default)(t,[{key:"closed",get:function(){return this._closed}},{key:"data",get:function(){return this._data},set:function(e){throw new Error("Setting the whole data object is not possible!")}},{key:"peers",get:function(){return this._peers},set:function(e){throw new Error("Setting the whole peers object is not possible!")}},{key:"transports",get:function(){return{produce:this._sendTransport,consume:this._recvTransport}},set:function(e){throw new Error("Setting of transport is not possible!")}},{key:"videoStream",get:function(){return this._webCamStream}},{key:"audioStream",get:function(){return this._micStream}},{key:"clientAgent",get:function(){return this._client}},{key:"activeParameters",get:function(){return this._data.inputParams}},{key:"deviceList",get:function(){return this._deviceList?this._deviceList:{videoDevices:[],audioDevices:[],audioOutputDevices:[]}},set:function(e){throw new Error("Setting of deviceList is not possible!")}},{key:"currentlyActiveSpeaker",get:function(){return this._activeSpeaker},set:function(e){throw new Error("Setting of currentActivespeaker is not possible!")}},{key:"roomDisplayName",get:function(){return this._roomDisplayName},set:function(e){throw new Error("Setting of roomDisplayName is not possible!")}},{key:"initLocal",value:(X=(0,c.default)(o.default.mark((function e(){var t;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=m.detectDevice(),U.debug("The device is:%O",t),e.next=4,this._initSocket();case 4:case"end":return e.stop()}}),e,this)}))),function(){return X.apply(this,arguments)})},{key:"_initSocket",value:(Y=(0,c.default)(o.default.mark((function e(){var t,r,i,n=this;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this,r=this.data.signallingServerUrl.replace(/^(http|https):\/\//,""),i="wss://".concat("".concat(r),"/?sessionToken=",this.data.sessionToken,"&roomId=").concat(this.data.inputParams.roomId,"&peerId=").concat(this.data.inputParams.peerId,"&roomType=").concat(this.data.inputParams.roomType),U.info("Going to create a new socket! with address: ".concat(r)),this._socket=new g.WebSocketTransport(i,!0),this._listenToSocket(),this._socket.on("notify",(function(e){var t=e.type,r=e.title,i=e.message;n.emit("notification",{eventType:t,eventText:"".concat(r,": ").concat(i),roomId:n.data.inputParams.roomId,peerId:n.data.inputParams.peerId})})),this._socket.on("roomStartedP2p",(function(e){U.info("P2P room successfully started"),n._running=!0})),this._socket.on("userError",(function(e){U.error("User Error happened with message:%O",e),t.emit("notification",{eventType:e.title,eventText:"".concat(e.text)})})),this._socket.on("validationAlert",(function(e){U.info("Validation alert happened")})),this._socket.on("alreadyActive",(function(e){e.title,e.text,n.emit("notification",{eventType:"alreadyActive",eventText:"This peer already has an active connection",roomId:n.data.inputParams.roomId,peerId:n.data.inputParams.peerId})})),this._socket.on("passwordDisabled",(function(){U.info("password disabled by moderator!"),n.emit("notification",{eventType:"passwordDisabled",eventText:"Password for this room has been disabled by moderator",roomId:n.data.inputParams.roomId})})),this._socket.on("close",(function(e){var t=e.code,r=e.reason;if(U.info("socket closed with code ".concat(t)),4500!==t&&4100!==t){var i=r||"Connection to server closed unexpectedly! Trying to reconnect.";U.info("socket close code is".concat(t," with reason ").concat(i))}else U.info("Socket is now closed!"),n.close()})),this._socket.on("connected",(0,c.default)(o.default.mark((function e(){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:U.info("Socket connected"),t.pc&&t._sendTransport&&t._recvTransport?roomType===x._security.roomType.P2P&&t.pc?(U.info("Socket seems to be reconnected in mid call! RestartIce needed for p2p call."),"failed"!==t.pc.iceConnectionState&&"disconnected"!==t.pc.iceConnectionState||t.restartICE()):(U.debug("Ice restarts for mediasoup transports for a joined peer"),t._sendTransport&&["Failed","disconnected"].includes(t._sendTransport.connectionState)?(U.debug("Restart ice for sendtransport"),t.restartIce(t._sendTransport.id,"send")):U.error("Send transport not available!"),t._recvTransport&&["Failed","disconnected"].includes(t._recvTransport.connectionState)?(U.debug("Restart ice for recvtransport"),t.restartIce(t._recvTransport.id,"recv")):U.error("Recv transport not available!")):(U.info("Connection getting connected for first time"),n.emit("initSuccess"));case 2:case"end":return e.stop()}}),e)})))),this._socket.on("defaultJoinStatus",function(){var e=(0,c.default)(o.default.mark((function e(t){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:U.info(" Socket defaultjoinstatus:%O",t);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());case 15:case"end":return e.stop()}}),e,this)}))),function(){return Y.apply(this,arguments)})},{key:"_sendMessage",value:function(e){this._socket.send(j({usageType:"sdk"},e))}},{key:"_listenToSocket",value:function(){var e=this;this._socket.on("message",(function(t){try{switch("currentlyActiveSpeaker"===t.id||"allStats"===t.id||U.info("message in Room is:%O",t),t.id){case"chatMessage":e.processChatMessage(t);break;case"customMessage":e.processCustomMessage(t);break;case"existingParticipants":e.onExistingParticipants(t);break;case"newPeerJoin":e.onNewPeer(t);break;case"recordingError":e.handleRecordingErrors(t);break;case"moderatorAuthentication":e.authenticateUser(t);break;case"authenticationRequested":e.authenticationRequested(t);break;case"toggleMyMic":e.toggleMyMic(t);break;case"toggleMyCamera":e.toggleMyCamera(t);break;case"logMeOut":e.logMeOutNew(t);break;case"userAlreadyAuthenticated":e.hideUserAuthenticationDialog(t);break;case"peerLeft":e.peerLeft(t);break;case"recordingStarted":e.setRecordingStatusStarted(t);break;case"recordingStopped":e.setRecordingStatusEnded(t);break;case"startDefaultRecording":e.startRecording(t);break;case"mediaToggled":e.mediaToggled(t);break;case"processingStarted":e.handleProcessingStart(t);break;case"processingCompleted":e.handleProcessingCompletion(t);break;case"processingError":e.handleProcessingError(t);break;case"createTransportResponse":e.handleCreateTransportRequest(t);break;case"connectTransportResponse":e.handleConnectTransportRequest(t);break;case"connectRecvTransportResponse":e.handleConnectRecvTransportRequest(t);break;case"sendTrackResponse":e.handleSendTrackRequest(t);break;case"recvTrackResponse":e.handleRecvTrackRequest(t);break;case"roomClosedByModerator":e.leaveRoomCommon(),e.roomClosed();break;case"currentlyActiveSpeaker":e.setCurrentlyActiveSpeaker(t);break;case"restartIceResponse":e.restartIceResponse(t);break;case"consumerClosed":e.closeConsumer(t);break;case"handRaise":e.handleHandRaise(t);break;case"updateCId":e.updateCId(t);break;case"upgradeParticipant":e.handleUpgradeParticipant(t);break;case"downgradeParticipant":e.handleDowngradeParticipant(t);break;case"switchMicOff":e.handleSwitchMicOff(t);break;case"screenShareLimitReached":e.handleScreenShareLimitReached(t);break;case"upgradeLimitReached":e.handleUpgradeLimitReached(t);break;case"modUpgradeReq":e.handleModUpgradeReq(t);break;case"lockUnlockRoom":e.handleLockUnlockRoom(t);break;case"peersWaiting":e.handlePeersWaiting(t);break;case"remotePeerJoin":e.handleRemotePeerJoin(t);break;case"offer":U.debug("inside offer"),e.handleOffer(t);break;case"answer":U.debug("inside answer"),e.handleAnswer(t);break;case"candidate":U.debug("inside handle candidate"),e.handleCandidate(t.candidate);break;case"p2pRoomClosed":U.debug("inside p2p room close"),e.leaveRoomNewP2p(x.ROOM_LEAVE_AND_CLOSE);break;case"p2pUserLeft":U.debug("inside p2p user left"),e.userLeftRoom(t);break;case"iceRestart":e.handleIceRestart(t);break;case"iceRestarted":e.handleIceRestartResponse(t);break;case"screenShareP2p":e.handleScreenShareP2p(t);break;default:U.warn("Unrecognized message:%o",t)}}catch(e){U.error("listentomessage:%O",e)}}))}},{key:"onNewPeer",value:function(e){var t=e.peerId,r=e.displayName,i=e.participantType;this._peers.set(t,{displayName:r,participantType:i,consumers:[]}),this.emit("newPeer",{peerId:t,peerName:r,type:this.data.inputParams.peerId===t?"local":"remote",peerRole:i})}},{key:"onExistingParticipants",value:(J=(0,c.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U.debug("Onexisting participant message:%O",t),this._routerRtpCapabilities=t.routerRtpCapabilities,this._roomStatus="connected",this._roomDisplayName=t.roomDisplayName,this._running=!0,this._socket._roomJoined=!0,this.emit("newPeer",{peerId:this.data.inputParams.peerId,peerName:this.data.inputParams.peerName,type:"local",peerRole:this.data.inputParams.peerType}),!this.data.inputParams.produce){e.next=12;break}return e.next=10,this._createSendTransport();case 10:e.next=13;break;case 12:U.debug("Produce is false!");case 13:if(!this.data.inputParams.consume){e.next=20;break}return e.next=16,this._createRecvTransport();case 16:r=this,t.peers&&t.peers.length>0&&t.peers.forEach((function(e){r.emit("newPeer",{peerId:e.peerId,peerName:e.name,type:"remote",peerRole:e.participantType})})),e.next=21;break;case 20:U.debug("Consume is false!");case 21:case"end":return e.stop()}}),e,this)}))),function(e){return J.apply(this,arguments)})},{key:"setCurrentlyActiveSpeaker",value:function(e){var t=e.activeSpeaker,r=t.peerId,i=t.volume;this._activeSpeaker=e.activeSpeaker,this.emit("activeSpeaker",{peerId:r,volume:i})}},{key:"close",value:function(){this._closed||(this._closed=!0,this._socket=null,this.data.inputParams={},U.info("Room close()"),this._sendTransport&&this._sendTransport.close(),this._recvTransport&&this._recvTransport.close(),this._roomStatus="closed",this._running=!1)}},{key:"leaveRoom",value:($=(0,c.default)(o.default.mark((function e(){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:U.debug("Leave room is called!!"),"connected"===this._roomStatus?(this._sendMessage({id:"leaveRoomNew",peerId:this.data.inputParams.peerId,roomLeaveType:"client"}),this.leaveRoomCommon()):U.error("The room state is:%s",this._roomStatus);case 2:case"end":return e.stop()}}),e,this)}))),function(){return $.apply(this,arguments)})},{key:"closeRoom",value:(K=(0,c.default)(o.default.mark((function e(){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:"connected"===this._roomStatus?(this._sendMessage({id:"leaveAndCloseRoom",peerId:this.data.inputParams.peerId,roomCloseType:"client"}),this.leaveRoomCommon()):U.error("The room state is:%s",this._roomStatus);case 1:case"end":return e.stop()}}),e,this)}))),function(){return K.apply(this,arguments)})},{key:"listDevicesInternal",value:(H=(0,c.default)(o.default.mark((function e(){var t,r=this;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices.ondevicechange=function(){var e=(0,c.default)(o.default.mark((function e(t){var i;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,M.updatedDeviceList)();case 2:i=e.sent,U.info("Media devices changed!:%O",i),i.audioDevices&&i.audioDevices.length>0&&(r._deviceList.audioDevices=i.audioDevices),i.videoDevices&&i.videoDevices.length>0&&(r._deviceList.videoDevices=i.videoDevices),i.audioDevices&&i.audioDevices.length>0&&(r._deviceList.audioOutputDevices=i.audioDevicesOutput),F=r._deviceList,r.emit("deviceListUpdated");case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),!this._deviceList){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,(0,M.loadAllAvailableDevices)();case 7:if(!(t=e.sent).success){e.next=12;break}return this._deviceList=t.deviceList,F=this._deviceList,e.abrupt("return");case 12:case"end":return e.stop()}}),e,this)}))),function(){return H.apply(this,arguments)})},{key:"enableMic",value:(W=(0,c.default)(o.default.mark((function e(){var t,r,i,n,a,s,c,d,u,l,h,f,p=this,m=arguments;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=m.length>0&&void 0!==m[0]?m[0]:{}).deviceId,i=void 0===r?null:r,n=t.autoGainControl,a=t.noiseSuppression,s=t.echoCancellation,c=t.channelCount,d=t.sampleRate,u=t.forcePCMU,l=t.forcePCMA,U.debug("enableMic()"),this.data.inputParams.produce){e.next=7;break}return U.debug("Produce status is set to false!"),e.abrupt("return",{success:!1,error:!0,code:"REID007",text:"Error while trying to start Mic/Audio. Produce flag need to set to true while joining room in order to enable Mic/Audio."});case 7:if("connected"===this._roomStatus){e.next=12;break}return U.debug("Room status is not connected yet!"),e.abrupt("return",{success:!1,error:!0,code:"REID008",text:"Error while trying to start Mic/Audio as room not in connected status. Current room status:!".concat(this._roomStatus),possibleReasons:"Did you forget to call joinRoom before enabling Mic? OR if you have already initiated the joinRoom process, then Mic will be enabled automatically once room join process completes."});case 12:if(!this._micProducer){e.next=17;break}return U.debug("Mic is already active!"),e.abrupt("return",{success:!1,warning:!0,code:"RWID002",text:"Error while trying to start Mic/Audio. Mic/Audio is already active!"});case 17:if(this._device.canProduce("audio")){e.next=20;break}return U.error("enableMic() | cannot produce audio"),e.abrupt("return",{success:!1,error:!0,code:"REID009",text:"Error while trying to start Mic/Audio. Mic/Audio couldnot be activated due to limitations on this device. If you think this device has a functional Mic and the problem persists even after multiple retries, please contact technical support with the error code."});case 20:if(u&&"boolean"==typeof u&&(this.data.inputParams.forcePCMU=u),l&&"boolean"==typeof l&&(this.data.inputParams.forcePCMA=l),n&&"boolean"==typeof n&&(this.data.inputParams.autoGainControl=n),s&&"boolean"==typeof s&&(this.data.inputParams.echoCancellation=s),a&&"boolean"==typeof a&&(this.data.inputParams.noiseSuppression=a),d&&Number.isInteger(d)&&d<64e3&&d>8e3&&(this.data.inputParams.sampleRate=d),c&&Number.isInteger(c)&&c>0&&c<3&&(this.data.inputParams.channelCount=c),e.prev=27,this._externalVideo){e.next=48;break}if(i?(f=this._deviceList.audioDevices.find((function(e){return e.deviceId===i})))||(U.warn("Selected audio input deviceId:%s not found",i),f=this._deviceList.audioDevices[0]):f=this._deviceList.audioDevices[0],this._mic.device=f,f){e.next=34;break}return U.error("No mic device found! Can't start audio!"),e.abrupt("return",{success:!1,reason:"No mic available for starting audio!"});case 34:return i&&this.data.inputParams.audioDeviceId!==i&&(this.data.inputParams.audioDeviceId=i),U.debug("enableMic() | calling getUserMedia()"),e.prev=36,e.next=39,navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:f.deviceId},echoCancellation:this.data.inputParams.echoCancellation,noiseSuppression:this.data.inputParams.noiseSuppression,autoGainControl:this.data.inputParams.autoGainControl,sampleRate:this.data.inputParams.sampleRate,channelCount:this.data.inputParams.channelCount}});case 39:this._micStream=e.sent,h=this._micStream.getAudioTracks()[0],e.next=46;break;case 43:throw e.prev=43,e.t0=e.catch(36),new Error("Error while acquiring mic. Possible issue with audio constraint values",e.t0);case 46:e.next=52;break;case 48:return e.next=50,this._getExternalVideoStream();case 50:this._micStream=e.sent,h=this._micStream.getAudioTracks()[0].clone();case 52:return e.next=54,this._sendTransport.produce({track:h,codecOptions:this.data.inputParams.forcePCMU||this.data.inputParams.forcePCMA?void 0:{opusStereo:!1,opusDtx:!0,opusFec:!0,opusNack:!0},codec:this.data.inputParams.forcePCMU?this._device.rtpCapabilities.codecs.find((function(e){return"audio/pcmu"===e.mimeType.toLowerCase()})):this.data.inputParams.forcePCMA?this._device.rtpCapabilities.codecs.find((function(e){return"audio/pcma"===e.mimeType.toLowerCase()})):void 0,appData:{mediaTag:"cam-audio"}});case 54:this._micProducer=e.sent,this._producers.set("audio",{id:this._micProducer.id,paused:this._micProducer.paused,track:this._micProducer.track,rtpParameters:this._micProducer.rtpParameters,codec:this._micProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("micStart",{peerId:this.data.inputParams.peerId,audioTrack:this._micProducer.track,type:"local"}),this._micProducer.on("transportclose",(function(){p._micProducer=null})),this._micProducer.on("trackended",(function(){p.disableMic().catch((function(){}))})),e.next=66;break;case 61:e.prev=61,e.t1=e.catch(27),U.error("enableMic() | failed:%o",e.t1),this.emit("error",{code:"EID002",text:"Error enabling microphone!"}),h&&h.stop();case 66:case"end":return e.stop()}}),e,this,[[27,61],[36,43]])}))),function(){return W.apply(this,arguments)})},{key:"disableMic",value:(G=(0,c.default)(o.default.mark((function e(){var t;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U.debug("disableMic()"),this._micStream&&this._micStream.getAudioTracks().forEach((function(e){return e.stop()})),this._micProducer){e.next=4;break}return e.abrupt("return");case 4:this._micProducer.close(),this._producers.delete("audio");try{t={id:"closeProducerSDK",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"audio",producerId:this._micProducer.id},this._sendMessage(t),this.emit("micEnd",{peerId:this.data.inputParams.peerId,audioTrack:null,type:"local"})}catch(e){this.emit("error",{code:"EID003",text:"Error disabling microphone!"})}this._micProducer=null;case 8:case"end":return e.stop()}}),e,this)}))),function(){return G.apply(this,arguments)})},{key:"muteMic",value:(V=(0,c.default)(o.default.mark((function e(){var t;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:U.debug("muteMic()"),this._micProducer.pause();try{t={id:"toggleMedia",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"audio",audioStatus:!1,producerId:this._micProducer.id},this._sendMessage(t),this.emit("peerMuted",{peerId:this.data.inputParams.peerId,type:"local"})}catch(e){U.error("muteMic() | failed: %o",e),this.emit("error",{code:"EID004",text:"Error muting local microphone!"})}case 3:case"end":return e.stop()}}),e,this)}))),function(){return V.apply(this,arguments)})},{key:"unmuteMic",value:(N=(0,c.default)(o.default.mark((function e(){var t;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:U.debug("unmuteMic()"),this._micProducer.resume();try{t={id:"toggleMedia",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"audio",audioStatus:!0,producerId:this._micProducer.id},this._sendMessage(t),this.emit("peerUnMuted",{peerId:this.data.inputParams.peerId,type:"local"})}catch(e){U.error("unmuteMic() | failed: %o",e),this.emit("error",{code:"EID005",text:"Error unmuting local microphone!"})}case 3:case"end":return e.stop()}}),e,this)}))),function(){return N.apply(this,arguments)})},{key:"enableCam",value:(L=(0,c.default)(o.default.mark((function e(){var t,r,i,n,a,s,c,d,u,l,h,f,p,m,b,g,v,y,_,w=this,S=arguments;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=S.length>0&&void 0!==S[0]?S[0]:{}).deviceId,i=void 0===r?null:r,n=t.videoResolution,a=t.forceVp8,s=t.forceVp9,c=t.forceH264,d=t.h264Profile,u=t.forceFPS,l=t.enableWebcamLayers,h=t.numSimulcastStreams,f=t.videoBitRates,U.debug("enableWebcam()"),this.data.inputParams.produce){e.next=7;break}return U.debug("Produce status is set to false!"),e.abrupt("return",{success:!1,error:!0,code:"REID004",text:"Error while trying to start Camera. Produce flag need to set to true while joining room in order to enable Camera."});case 7:if("connected"===this._roomStatus){e.next=10;break}return U.debug("Room status is not connected yet!"),e.abrupt("return",{success:!1,error:!0,code:"REID005",text:"Error while trying to start Camera as room not in connected status. Current room status:!".concat(this._roomStatus),possibleReasons:"Did you forget to call joinRoom before enabling Camera? OR if you have already initiated the joinRoom process, then Camera will be enabled automatically once room join process completes."});case 10:if(!this._webcamProducer){e.next=13;break}return U.debug("Camera is already active!"),e.abrupt("return",{success:!1,warning:!0,code:"RWID003",text:"Error while trying to start Camera. Camera is already active!"});case 13:if(this._device.canProduce("video")){e.next=16;break}return U.error("enableWebcam() | cannot produce video"),e.abrupt("return",{success:!1,error:!0,code:"REID006",text:"Error while trying to start Camera. Camera couldnot be activated due to limitations on this device. If you think this device has a functional camera and the problem persists even after multiple retries, please contact technical support with the error code."});case 16:if(["hd","vga","qvga"].includes(n)&&(this.data.inputParams.videoResolution=n,this._webcam.resolution=n),a&&"boolean"==typeof a&&(this.data.inputParams.forceVp8=a),s&&"boolean"==typeof s&&(this.data.inputParams.forceVp9=s),c&&"boolean"==typeof c&&(this.data.inputParams.forceH264=c),d&&["high","low"].includes(d.toLowerCase())&&(this.data.inputParams.h264Profile=d),u&&Number.isInteger(u)&&u<65&&u>5&&(this.data.inputParams.forceFPS=25),l&&"boolean"==typeof l&&(this.data.inputParams.enableWebcamLayers=l,this._enableWebcamLayers=l),h&&Number.isInteger(h)&&h<4&&h>0&&(this.data.inputParams.numSimulcastStreams=h,this._numSimulcastStreams=h),Array.isArray(f)&&f.length>=1&&f.length<=3&&f.every((function(e){return Number.isInteger(e)&&e>=75&&e<=800}))?(U.debug("videoBitRates values are correct"),this.data.inputParams.videoBitRates=f):U.warn("videobitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[700,250,75]'"),e.prev=25,this._externalVideo){e.next=41;break}if(i?(m=this._deviceList.videoDevices.find((function(e){return e.deviceId===i})))||(U.warn("Selected deviceId:%s not found",i),m=this._deviceList.videoDevices[0]):m=this._deviceList.videoDevices[0],this._webcam.device=m,b=this._webcam.resolution,m){e.next=33;break}return U.error("No wencam device found! Can't start video!"),e.abrupt("return",{success:!1,reason:"No Webcam available for starting video!"});case 33:return i&&this.data.inputParams.videoDeviceId!==i&&(this.data.inputParams.videoDeviceId=i),U.debug("enableWebcam() | calling getUserMedia()"),e.next=37,navigator.mediaDevices.getUserMedia({video:j(j({deviceId:{exact:m.deviceId}},q[b]),{},{frameRate:{ideal:this.data.inputParams.forceFPS}})});case 37:this._webCamStream=e.sent,p=this._webCamStream.getVideoTracks()[0],e.next=46;break;case 41:return m={label:"external video"},e.next=44,this._getExternalVideoStream();case 44:this._webCamStream=e.sent,p=this._webCamStream.getVideoTracks()[0].clone();case 46:if(y={videoGoogleStartBitrate:1e3},U.debug("Current device codec options are:%O",this._device.rtpCapabilities.codecs),!this._forceVP8){e.next=54;break}if(v=this._device.rtpCapabilities.codecs.find((function(e){return"video/vp8"===e.mimeType.toLowerCase()}))){e.next=52;break}throw new Error("desired VP8 codec+configuration is not supported");case 52:e.next=67;break;case 54:if(!this._forceH264){e.next=63;break}if("high"===this.data.inputParams.h264Profile?v=this._device.rtpCapabilities.codecs.find((function(e){return"video/h264"===e.mimeType.toLowerCase()&&"4d001f"===e.parameters["profile-level-id"]})):"low"===this.data.inputParams.h264Profile&&(v=this._device.rtpCapabilities.codecs.find((function(e){return"video/h264"===e.mimeType.toLowerCase()&&"42e01f"===e.parameters["profile-level-id"]}))),v){e.next=60;break}throw new Error("desired H264 codec+configuration is not supported");case 60:U.debug("Selected h264 codec is:%O",v);case 61:e.next=67;break;case 63:if(!this._forceVP9){e.next=67;break}if(v=this._device.rtpCapabilities.codecs.find((function(e){return"video/vp9"===e.mimeType.toLowerCase()}))){e.next=67;break}throw new Error("desired VP9 codec+configuration is not supported");case 67:return this._enableWebcamLayers&&(_=this._device.rtpCapabilities.codecs.find((function(e){return"video"===e.kind})),this._forceVP9&&v||"video/vp9"===_.mimeType.toLowerCase()?g=[{maxBitrate:5e6,scalabilityMode:this._webcamScalabilityMode||"L3T3_KEY"}]:(g=[{scaleResolutionDownBy:1,maxBitrate:1e3*this.data.inputParams.videoBitRates[0],scalabilityMode:this._webcamScalabilityMode||"L1T3"}],this._numSimulcastStreams>1&&g.unshift({scaleResolutionDownBy:2,maxBitrate:1e3*this.data.inputParams.videoBitRates[1],scalabilityMode:this._webcamScalabilityMode||"L1T3"}),this._numSimulcastStreams>2&&g.unshift({scaleResolutionDownBy:4,maxBitrate:1e3*this.data.inputParams.videoBitRates[2],scalabilityMode:this._webcamScalabilityMode||"L1T3"}))),e.next=70,this._sendTransport.produce({track:p,encodings:g,codecOptions:y,codec:v,appData:{mediaTag:"cam-video"}});case 70:this._webcamProducer=e.sent,this._producers.set("video",{id:this._webcamProducer.id,deviceLabel:m.label,type:this._getWebcamType(m),paused:this._webcamProducer.paused,track:this._webcamProducer.track,rtpParameters:this._webcamProducer.rtpParameters,codec:this._webcamProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("videoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._webcamProducer.track,type:"local"}),this._webcamProducer.on("transportclose",(function(){w._webcamProducer=null})),this._webcamProducer.on("trackended",(function(){w.disableCam().catch((function(){}))})),e.next=82;break;case 77:e.prev=77,e.t0=e.catch(25),U.error("enableWebcam() | failed:%o",e.t0),this.emit("error",{code:"EID011",text:"Enable Webcam failed!"}),p&&p.stop();case 82:case"end":return e.stop()}}),e,this,[[25,77]])}))),function(){return L.apply(this,arguments)})},{key:"disableCam",value:(A=(0,c.default)(o.default.mark((function e(){var t;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U.debug("disableWebcam()"),this._webcamProducer){e.next=3;break}return e.abrupt("return");case 3:this._webcamProducer.close(),this._producers.delete("video");try{t={id:"closeProducerSDK",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"video",producerId:this._webcamProducer.id},this._sendMessage(t),this.emit("videoEnd",{peerId:this.data.inputParams.peerId,videoTrack:null})}catch(e){this.emit("error",{code:"EID012",text:"Error while closing server side producer!"})}this._webcamProducer=null;case 7:case"end":return e.stop()}}),e,this)}))),function(){return A.apply(this,arguments)})},{key:"_updateWebcams",value:(D=(0,c.default)(o.default.mark((function e(){var t,r,i,n,a,s,c;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return U.debug("_updateWebcams()"),this._webcams=new Map,U.debug("_updateWebcams() | calling enumerateDevices()"),e.next=5,navigator.mediaDevices.enumerateDevices();case 5:t=e.sent,r=O(t),e.prev=7,r.s();case 9:if((i=r.n()).done){e.next=16;break}if("videoinput"===(n=i.value).kind){e.next=13;break}return e.abrupt("continue",14);case 13:this._webcams.set(n.deviceId,n);case 14:e.next=9;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(7),r.e(e.t0);case 21:return e.prev=21,r.f(),e.finish(21);case 24:a=Array.from(this._webcams.values()),s=a.length,c=this._webcam.device?this._webcam.device.deviceId:void 0,U.debug("_updateWebcams() [webcams:%o]",a),0===s?this._webcam.device=null:this._webcams.has(c)||(this._webcam.device=a[0]);case 29:case"end":return e.stop()}}),e,this,[[7,18,21,24]])}))),function(){return D.apply(this,arguments)})},{key:"_getExternalVideoStream",value:(I=(0,c.default)(o.default.mark((function e(){var t=this;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._externalVideoStream){e.next=2;break}return e.abrupt("return",this._externalVideoStream);case 2:if(!(this._externalVideo.readyState<3)){e.next=5;break}return e.next=5,new Promise((function(e){return t._externalVideo.addEventListener("canplay",e)}));case 5:if(!this._externalVideo.captureStream){e.next=9;break}this._externalVideoStream=this._externalVideo.captureStream(),e.next=14;break;case 9:if(!this._externalVideo.mozCaptureStream){e.next=13;break}this._externalVideoStream=this._externalVideo.mozCaptureStream(),e.next=14;break;case 13:throw new Error("video.captureStream() not supported");case 14:return e.abrupt("return",this._externalVideoStream);case 15:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"_getWebcamType",value:function(e){return/(back|rear)/i.test(e.label)?(U.debug("_getWebcamType() | it seems to be a back camera"),"back"):(U.debug("_getWebcamType() | it seems to be a front camera"),"front")}},{key:"changeVideoInput",value:(_=(0,c.default)(o.default.mark((function e(t){var r,i,n,a;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.resolution,i=t.deviceId,n=t.fps,!this._webcamProducer){e.next=8;break}return e.next=4,this._changeVideoInput({resolution:r,deviceId:i,fps:n});case 4:return a=e.sent,e.abrupt("return",a);case 8:return U.error("No webcam producer available!"),e.abrupt("return",{success:!1,reason:"You are not sharing your camera yet. Camera Input can be changed to a new camera only when you are sharing an existing camera. "});case 10:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"_changeVideoInput",value:(y=(0,c.default)(o.default.mark((function e(t){var r,i,n,a,s,c;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.resolution,i=t.deviceId,n=t.fps,U.info("_changeVideoInput() | Inside"),r&&["hd","vga","qvga"].includes(r)?this._webcam.resolution=r:U.warn("Invalid video resolution value "),n&&Number.isInteger(n)&&n<65&&n>5?this.data.inputParams.forceFPS=n:U.warn("forceFPS should be a number between 5 to 65, default value is 25 fps."),a=this._deviceList.videoDevices.find((function(e){return i&&e.deviceId===i}))){e.next=8;break}return U.error("The selected deviceId not found!"),e.abrupt("return",{success:!1,reason:"Invalid deviceId!"});case 8:return this._webcam.device=a,e.prev=9,this._webCamStream.getVideoTracks().forEach((function(e){return e.stop()})),this._webCamStream=null,U.debug("changeVideoInput() | calling getUserMedia()"),e.next=15,navigator.mediaDevices.getUserMedia({video:j(j({deviceId:{exact:a.deviceId}},q[this._webcam.resolution]),{},{frameRate:{ideal:this.data.inputParams.forceFPS}})});case 15:return this._webCamStream=e.sent,s=this._webCamStream.getVideoTracks()[0],U.debug("The new video track is:%O",s),e.next=20,this._webcamProducer.replaceTrack({track:s});case 20:return(c=this._producers.get("video")).deviceLabel=a.label,c.type=this._getWebcamType(a),c.track=this._webcamProducer.track,U.debug("Updated producer values are:%O",c),this._producers.set("video",c),this.emit("videoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._webcamProducer.track,type:"local"}),e.abrupt("return",{success:!0});case 30:return e.prev=30,e.t0=e.catch(9),U.error("Error while changing input:%O",e.t0),e.abrupt("return",{success:!1,reason:"Couldn't change video input",error:e.t0});case 34:case"end":return e.stop()}}),e,this,[[9,30]])}))),function(e){return y.apply(this,arguments)})},{key:"changeAudioInput",value:(v=(0,c.default)(o.default.mark((function e(t){var r,i,n,a,s,c,d;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.autoGainControl,i=t.echoCancellation,n=t.noiseSuppression,a=t.sampleRate,s=t.channelCount,c=t.deviceId,!this._micProducer){e.next=8;break}return e.next=4,this._changeAudioInput({autoGainControl:r,echoCancellation:i,noiseSuppression:n,sampleRate:a,channelCount:s,deviceId:c});case 4:return d=e.sent,e.abrupt("return",d);case 8:return e.abrupt("return",{success:!1,reason:"You are not sharing your mic yet. Mic Input can be changed to a new mic only when you are sharing an existing mic. "});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"_changeAudioInput",value:(h=(0,c.default)(o.default.mark((function e(t){var r,i,n,a,s,c,d,u,l;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.autoGainControl,i=t.echoCancellation,n=t.noiseSuppression,a=t.sampleRate,s=t.channelCount,c=t.deviceId,r&&"boolean"==typeof r&&(this.data.inputParams.autoGainControl=r),i&&"boolean"==typeof i&&(this.data.inputParams.echoCancellation=Boolean(i)),n&&"boolean"==typeof n&&(this.data.inputParams.noiseSuppression=Boolean(n)),a&&Number.isInteger(a)&&a<64e3&&a>8e3&&(this.data.inputParams.sampleRate=a),s&&Number.isInteger(s)&&s>0&&s<3&&(this.data.inputParams.channelCount=s),d=this._deviceList.audioDevices.find((function(e){return c&&e.deviceId===c}))){e.next=9;break}return e.abrupt("return",{success:!1,reason:"Invalid deviceId!"});case 9:return this._mic.device=d,this._micStream&&this._micStream.getAudioTracks().forEach((function(e){return e.stop()})),this._micStream=null,e.prev=12,e.next=15,navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:d.deviceId},echoCancellation:this.data.inputParams.echoCancellation,noiseSuppression:this.data.inputParams.noiseSuppression,autoGainControl:this.data.inputParams.autoGainControl,sampleRate:this.data.inputParams.sampleRate,channelCount:this.data.inputParams.channelCount}});case 15:return this._micStream=e.sent,u=this._micStream.getAudioTracks()[0],this._micProducer.replaceTrack({track:u}),(l=this._producers.get("audio")).deviceLabel=d.label,l.track=this._micProducer.track,U.debug("Updated producer values are:%O",l),this._producers.set("audio",l),this.emit("micStart",{peerId:this.data.inputParams.peerId,audioTrack:this._micProducer.track,type:"local"}),e.abrupt("return",{success:!0});case 27:return e.prev=27,e.t0=e.catch(12),U.error("Error while changing input:%O",e.t0),e.abrupt("return",{success:!1,reason:"Couldn't change audio input",err:e.t0});case 31:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e){return h.apply(this,arguments)})},{key:"enableShare",value:(l=(0,c.default)(o.default.mark((function e(){var t,r,i,n,a,s,c,d,u,l,h,f,p,m,b=this,g=arguments;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=g.length>0&&void 0!==g[0]?g[0]:{}).shareAudio,i=void 0!==r&&r,n=t.enableSharingLayers,a=void 0===n||n,s=t.shareBitRates,c=void 0===s?[2500,1250,500]:s,U.debug("enableShare()"),this.data.inputParams.produce){e.next=7;break}return U.debug("Produce status is set to false!"),e.abrupt("return",{success:!1,error:!0,code:"REID003",text:"Error while trying to start screen share. Produce flag need to set to true while joining room in order to enable screen share."});case 7:if("connected"===this._roomStatus){e.next=12;break}return U.debug("Room status is not connected yet!"),e.abrupt("return",{success:!1,error:!0,code:"REID001",text:"Error while trying to start screen share as room not in connected status. Current room status:!".concat(this._roomStatus),possibleReasons:"Did you forget to call joinRoom before enabling screen share? OR if you have already initiated the joinRoom process, then try enabling screen share after some seconds."});case 12:if(!this._shareProducer){e.next=17;break}return U.debug("Screen share is already active!"),e.abrupt("return",{success:!1,warning:!0,code:"RWID001",text:"Error while trying to start screen share. Screen share is already active!"});case 17:if(this._device.canProduce("video")){e.next=20;break}return U.error("enableShare() | cannot produce video"),e.abrupt("return",{success:!1,error:!0,code:"REID002",text:"Error while trying to start screen share. Screen share couldnot be activated due to limitations on this device. If you think this device is capable of screen share and the problem persists even after multiple retries, please contact technical support with the error code."});case 20:return this._enableSharingLayers="boolean"!=typeof a?Boolean(a):a,Array.isArray(c)&&c.length>=1&&c.length<=3&&c.every((function(e){return Number.isInteger(e)&&e>=500&&e<=2500}))?this.data.inputParams.shareBitRates=c:this.data.inputParams.shareBitRates=[2500,1250,500],e.prev=22,U.debug("enableShare() | calling getDisplayMedia()"),e.next=26,navigator.mediaDevices.getDisplayMedia({audio:!!i,video:{displaySurface:"monitor",logicalSurface:!0,cursor:!0,width:{max:1920},height:{max:1080},frameRate:{max:30}}});case 26:if(l=e.sent){e.next=31;break}return U.error("Unable to capture screen."),this.emit("error",{code:"EID013",text:"Error while trying to start screen share. Not able to capture screen!"}),e.abrupt("return");case 31:if(!(u=l.getAudioTracks()[0])){e.next=38;break}return e.next=35,this._sendTransport.produce({track:u,codecOptions:this.data.inputParams.forcePCMU?void 0:{opusStereo:!1,opusDtx:!0,opusFec:!0,opusNack:!0},codec:this.data.inputParams.forcePCMU?this._device.rtpCapabilities.codecs.find((function(e){return"audio/pcmu"===e.mimeType.toLowerCase()})):void 0,appData:{mediaTag:"screen-audio"}});case 35:this._shareAudioProducer=e.sent,this._producers.set("ssAudio",{id:this._shareAudioProducer.id,type:"shareAudio",paused:this._shareAudioProducer.paused,track:this._shareAudioProducer.track,rtpParameters:this._shareAudioProducer.rtpParameters,codec:this._shareAudioProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("ssAudioStart",{peerId:this.data.inputParams.peerId,audioTrack:this._shareAudioProducer.track,type:"local"});case 38:if(d=l.getVideoTracks()[0],p={videoGoogleStartBitrate:1e3},!this._forceVP8){e.next=46;break}if(f=this._device.rtpCapabilities.codecs.find((function(e){return"video/vp8"===e.mimeType.toLowerCase()}))){e.next=44;break}throw new Error("desired VP8 codec+configuration is not supported");case 44:e.next=59;break;case 46:if(!this._forceH264){e.next=55;break}if("high"===this.data.inputParams.h264Profile?f=this._device.rtpCapabilities.codecs.find((function(e){return"video/h264"===e.mimeType.toLowerCase()&&"4d001f"===e.parameters["profile-level-id"]})):"low"===this.data.inputParams.h264Profile&&(f=this._device.rtpCapabilities.codecs.find((function(e){return"video/h264"===e.mimeType.toLowerCase()&&"42e01f"===e.parameters["profile-level-id"]}))),f){e.next=52;break}throw new Error("desired H264 codec+configuration is not supported");case 52:U.debug("Selected h264 codec is:%O",f);case 53:e.next=59;break;case 55:if(!this._forceVP9){e.next=59;break}if(f=this._device.rtpCapabilities.codecs.find((function(e){return"video/vp9"===e.mimeType.toLowerCase()}))){e.next=59;break}throw new Error("desired VP9 codec+configuration is not supported");case 59:return this._enableSharingLayers&&(m=this._device.rtpCapabilities.codecs.find((function(e){return"video"===e.kind})),this._forceVP9&&f||"video/vp9"===m.mimeType.toLowerCase()?h=[{maxBitrate:1e3*this.data.inputParams.shareBitRates[0],scalabilityMode:this._sharingScalabilityMode||"L3T3",dtx:!0}]:(h=[{scaleResolutionDownBy:1,maxBitrate:1e3*this.data.inputParams.shareBitRates[0],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}],this._numSimulcastStreams>1&&h.unshift({scaleResolutionDownBy:2,maxBitrate:1e3*this.data.inputParams.shareBitRates[1],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}),this._numSimulcastStreams>2&&h.unshift({scaleResolutionDownBy:4,maxBitrate:1e3*this.data.inputParams.shareBitRates[2],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}))),e.next=62,this._sendTransport.produce({track:d,encodings:h,codecOptions:p,codec:f,appData:{mediaTag:"screen-video"}});case 62:this._shareProducer=e.sent,this._producers.set("ssVideo",{id:this._shareProducer.id,type:"shareVideo",paused:this._shareProducer.paused,track:this._shareProducer.track,rtpParameters:this._shareProducer.rtpParameters,codec:this._shareProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("ssVideoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._shareProducer.track,type:"local"}),this._shareProducer.on("transportclose",(function(){b._shareProducer=null})),this._shareProducer.on("trackended",(function(){b.disableShare().catch((function(){}))})),e.next=74;break;case 69:e.prev=69,e.t0=e.catch(22),U.error("enableShare() | failed:%o",e.t0),"NotAllowedError"!==e.t0.name&&this.emit("error",{code:"EID014",text:"Error while trying to start screen share. Error is: ".concat(e.t0,"!")}),d&&d.stop();case 74:case"end":return e.stop()}}),e,this,[[22,69]])}))),function(){return l.apply(this,arguments)})},{key:"disableShare",value:(n=(0,c.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U.debug("disableShare()"),this._shareProducer){e.next=5;break}return U.warn("Screen share doesn't seem to be on!"),this.emit("error",{code:"EID017",text:"Error while trying to stop screen share. Is the screen share on!"}),e.abrupt("return");case 5:if(this._shareProducer.close(),this._shareAudioProducer){this._shareAudioProducer.close();try{t={id:"closeProducerSDK",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"audio",producerId:this._shareAudioProducer.id},this._sendMessage(t),this.emit("ssAudioStop",{peerId:this.data.inputParams.peerId,videoTrack:null,type:"local"})}catch(e){this.emit("error",{code:"EID015",text:"Error while trying to stop screen share audio. Error is: ".concat(e,"!")})}}try{r={id:"closeProducerSDK",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"video",producerId:this._shareProducer.id},this._sendMessage(r),this.emit("ssVideoStop",{peerId:this.data.inputParams.peerId,videoTrack:null,type:"local"})}catch(e){this.emit("error",{code:"EID016",text:"Error while trying to stop screen share video. Error is: ".concat(e,"!")})}this._shareAudioProducer=null,this._shareProducer=null;case 10:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})}],[{key:"listDevices",value:(i=(0,c.default)(o.default.mark((function e(){var t;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!F){e.next=3;break}return U.info("Device list already exists:%O",F),e.abrupt("return",{success:!0,deviceList:F});case 3:return e.next=5,(0,M.loadAllAvailableDevices)();case 5:if(!(t=e.sent).success){e.next=11;break}return F=t.deviceList,e.abrupt("return",{success:!0,deviceList:t.deviceList});case 11:return e.abrupt("return",{success:!1,reason:t.reason});case 12:case"end":return e.stop()}}),e)}))),function(){return i.apply(this,arguments)})},{key:"init",value:(r=(0,c.default)(o.default.mark((function e(){var r,i,n,s,c,d,u,l,h,f=arguments;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=(r=f.length>0&&void 0!==f[0]?f[0]:{}).sessionToken,n=r.roomId,s=r.peerId,i){e.next=3;break}throw new Error("Session token is required to join the room.");case 3:e.prev=3,U.info("session token:%s",i),e.prev=5,c=E.default.verify(i,"samvyo_tech_321",{algorithms:["HS256"]}),U.info("Decoded token:",c),e.next=26;break;case 10:if(e.prev=10,e.t0=e.catch(5),U.error("JWT verification failed:",e.t0),"JsonWebTokenError"!==e.t0.name){e.next=17;break}throw new Error("Invalid session token: "+e.t0.message);case 17:if("TokenExpiredError"!==e.t0.name){e.next=21;break}throw new Error("Session token has expired");case 21:if("NotBeforeError"!==e.t0.name){e.next=25;break}throw new Error("Session token not yet active");case 25:throw new Error("Failed to verify session token: "+e.t0.message);case 26:if(c&&"object"===(0,a.default)(c)){e.next=28;break}throw new Error("Invalid token format");case 28:if(u=(d=c).data,l=d.signallingServerUrl,u&&l){e.next=31;break}throw new Error("Missing required token data");case 31:return s||(s=(0,k.uuidv4)()),n||(n=(0,S.getRandomInt)()),h={sessionToken:i,innerSessionToken:u,signallingServerUrl:l},e.abrupt("return",new t({peerId:s,roomId:n,outputData:h}));case 37:throw e.prev=37,e.t1=e.catch(3),U.error("Failed to initialize:",e.t1.message),e.t1;case 41:case"end":return e.stop()}}),e,null,[[3,37],[5,10]])}))),function(){return r.apply(this,arguments)})}]);var r,i,n,l,h,v,y,_,I,D,A,L,N,V,G,W,H,K,$,J,Y,X}(v.EventEmitter)},{"./Logger":4,"./socket":5,"./utils/chooseMedia":12,"./utils/constants":13,"./utils/getRandomInt":14,"./utils/getUSerMediaConstraints":15,"./utils/getVidScaleUrl":16,"./utils/queue":17,"./utils/randomName":18,"./utils/sleep":19,"./utils/uuidv4":20,"./utils/verifyOutputQualites":21,"./utils/verifyfileTypes":22,"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/defineProperty":27,"@babel/runtime/helpers/getPrototypeOf":28,"@babel/runtime/helpers/inherits":29,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/helpers/objectWithoutProperties":31,"@babel/runtime/helpers/possibleConstructorReturn":33,"@babel/runtime/helpers/typeof":38,"@babel/runtime/regenerator":39,bowser:61,events:91,jsonwebtoken:178,"mediasoup-client":232}],3:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault"),n=e("@babel/runtime/helpers/typeof");Object.defineProperty(r,"__esModule",{value:!0}),r.JsSdk_v1=void 0;var a=i(e("@babel/runtime/regenerator")),s=i(e("@babel/runtime/helpers/asyncToGenerator")),o=i(e("@babel/runtime/helpers/defineProperty")),c=i(e("@babel/runtime/helpers/classCallCheck")),d=i(e("@babel/runtime/helpers/createClass")),u=i(e("@babel/runtime/helpers/possibleConstructorReturn")),l=i(e("@babel/runtime/helpers/getPrototypeOf")),h=i(e("@babel/runtime/helpers/inherits")),f=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=n(e)&&"function"!=typeof e)return{default:e};var r=k(t);if(r&&r.has(e))return r.get(e);var i={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&{}.hasOwnProperty.call(e,s)){var o=a?Object.getOwnPropertyDescriptor(e,s):null;o&&(o.get||o.set)?Object.defineProperty(i,s,o):i[s]=e[s]}return i.default=e,r&&r.set(e,i),i}(e("mediasoup-client")),p=i(e("bowser")),m=i(e("./socket")),b=e("events"),g=i(e("./Logger")),v=e("./utils/getRandomInt"),y=e("./utils/uuidv4"),_=e("./utils/getVidScaleUrl"),w=i(e("./utils/randomName")),S=(e("./utils/constants"),e("./utils/chooseMedia"));function k(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(k=function(e){return e?r:t})(e)}function R(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return P(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function M(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 E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?M(Object(r),!0).forEach((function(t){(0,o.default)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function x(e,t,r){return t=(0,l.default)(t),(0,u.default)(e,T()?Reflect.construct(t,r||[],(0,l.default)(e).constructor):t.apply(e,r))}function T(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(T=function(){return!!e})()}var C,I=new g.default("Room"),D={small:{width:{ideal:160},height:{ideal:120}},qvga:{width:{ideal:320},height:{ideal:240}},vga:{width:{ideal:640},height:{ideal:480}},hd:{width:{ideal:1280},height:{ideal:720}}},O={optional:[{googDscp:!0}]};r.JsSdk_v1=function(e){function t(e){var r,i=e.peerId,n=e.roomId,a=e.peerName,s=e.produce,o=e.produceAudio,d=e.produceVideo,u=e.consume,l=e.videoResolution,h=e.forceVp8,m=e.forceVp9,b=e.forceH264,g=e.h264Profile,v=e.forceFPS,y=e.forcePCMU,_=e.forcePCMA,w=e.enableWebcamLayers,S=e.numSimulcastStreams,k=e.autoGainControl,R=e.echoCancellation,P=e.noiseSuppression,M=e.sampleRate,T=e.channelCount,I=e.videoBitRates,D=e.share,O=e.shareAudio,A=e.enableSharingLayers,L=e.shareBitRates,j=e.outputData,B=e.audioDeviceId,N=e.videoDeviceId;return(0,c.default)(this,t),(r=x(this,t))._closed=!1,r._roomStatus="initialised",r._cignal=null,r._sendTransport=null,r._recvTransport=null,r._device=new f.Device,r._webCamProducer=null,r._micProducer=null,r._shareProducer=null,r._shareAudioProducer=null,r._producers=new Map,r._consumers=new Map,r._peers=new Map,r._data=E({},j),r._micStream=null,r._webCamStream=null,r._webcam={device:null,resolution:l},r._mic={device:null},r._deviceList=C||null,r._externalVideo=null,r._externalVideoStream=null,r._forceVP8=Boolean(h),r._forceH264=Boolean(b),r._forceVP9=Boolean(m),r._enableWebcamLayers=Boolean(w),r._numSimulcastStreams=S,r._enableSharingLayers=Boolean(A),r._client=p.default.parse(window.navigator.userAgent),r._cignalConnected=!1,r._reconnectionInitiated=!1,r._restartIceInProgressSendTransport=!1,r._restartIceInProgressRecvTransport=!1,r._activeSpeaker=null,r.init({roomId:n,peerId:i,peerName:a,produce:s,produceAudio:o,produceVideo:d,consume:u,videoResolution:l,forceVp8:h,forceVp9:m,forceH264:b,h264Profile:g,forceFPS:v,forcePCMU:y,forcePCMA:_,enableWebcamLayers:w,numSimulcastStreams:S,autoGainControl:k,echoCancellation:R,noiseSuppression:P,sampleRate:M,channelCount:T,videoBitRates:I,share:D,shareAudio:O,enableSharingLayers:A,shareBitRates:L,audioDeviceId:B,videoDeviceId:N}),r}return(0,h.default)(t,e),(0,d.default)(t,[{key:"closed",get:function(){return this._closed}},{key:"data",get:function(){return this._data},set:function(e){throw new Error("Setting the whole data object is not possible!")}},{key:"peers",get:function(){return this._peers},set:function(e){throw new Error("Setting the whole peers object is not possible!")}},{key:"transports",get:function(){return{produce:this._sendTransport,consume:this._recvTransport}},set:function(e){throw new Error("Setting of transport is not possible!")}},{key:"videoStream",get:function(){return this._webCamStream}},{key:"audioStream",get:function(){return this._micStream}},{key:"clientAgent",get:function(){return this._client}},{key:"activeParameters",get:function(){return this._data.inputParams}},{key:"deviceList",get:function(){return this._deviceList?this._deviceList:{videoDevices:[],audioDevices:[],audioOutputDevices:[]}},set:function(e){throw new Error("Setting of deviceList is not possible!")}},{key:"currentlyActiveSpeaker",get:function(){return this._activeSpeaker},set:function(e){throw new Error("Setting of currentActivespeaker is not possible!")}},{key:"init",value:(H=(0,s.default)(a.default.mark((function e(t){var r;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return I.debug("init() | The input parameters are:%O",t),this.data.inputParams=t,r=f.detectDevice(),I.debug("The device is:%O",r),e.next=6,this.listDevicesInternal();case 6:return e.next=8,this.join();case 8:case"end":return e.stop()}}),e,this)}))),function(e){return H.apply(this,arguments)})},{key:"close",value:function(){this._closed||(this._closed=!0,I.debug("close()"),this._cignal.close(),this._sendTransport&&this._sendTransport.close(),this._recvTransport&&this._recvTransport.close(),this._roomStatus="closed")}},{key:"leaveRoom",value:(W=(0,s.default)(a.default.mark((function e(){return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(I.debug("Leave room is called!!"),"connected"!==this._roomStatus){e.next=12;break}return e.next=4,this._cignal.notify("leaveRoom",{});case 4:this._sendTransport&&(this._sendTransport.close(),this._sendTransport=null),this._recvTransport&&(this._recvTransport.close(),this._recvTransport=null),this._webCamStream&&this._webCamStream.getVideoTracks().forEach((function(e){e.stop(),I.debug("Video Track stopped")})),this._micStream&&this._micStream.getAudioTracks().forEach((function(e){e.stop(),I.debug("Mic Track stopped")})),this._roomStatus="closed",this._cignal.close(),e.next=13;break;case 12:I.error("The room state is:%s",this._roomStatus);case 13:case"end":return e.stop()}}),e,this)}))),function(){return W.apply(this,arguments)})},{key:"closeRoom",value:(G=(0,s.default)(a.default.mark((function e(){return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._cignal.notify("closeRoom",{});case 2:this.leaveRoom();case 3:case"end":return e.stop()}}),e,this)}))),function(){return G.apply(this,arguments)})},{key:"listDevicesInternal",value:(V=(0,s.default)(a.default.mark((function e(){var t,r=this;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices.ondevicechange=function(){var e=(0,s.default)(a.default.mark((function e(t){var i;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,S.updatedDeviceList)();case 2:i=e.sent,I.info("Media devices changed!:%O",i),i.audioDevices&&i.audioDevices.length>0&&(r._deviceList.audioDevices=i.audioDevices),i.videoDevices&&i.videoDevices.length>0&&(r._deviceList.videoDevices=i.videoDevices),i.audioDevices&&i.audioDevices.length>0&&(r._deviceList.audioOutputDevices=i.audioDevicesOutput),C=r._deviceList,r.emit("deviceListUpdated");case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),!this._deviceList){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,(0,S.loadAllAvailableDevices)();case 7:if(!(t=e.sent).success){e.next=12;break}return this._deviceList=t.deviceList,C=this._deviceList,e.abrupt("return");case 12:case"end":return e.stop()}}),e,this)}))),function(){return V.apply(this,arguments)})},{key:"join",value:(z=(0,s.default)(a.default.mark((function e(){var t,r=this;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=new m.default.SocketTransport(this.data.url,{retries:10,factor:2,minTimeout:1e3,maxTimeout:8e3}),this._cignal=new m.default.Peer(t),this._cignal.on("open",(0,s.default)(a.default.mark((function e(){var t,i;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r._cignalConnected=!0,!r._sendTransport&&!r._recvTransport){e.next=6;break}!r._sendTransport||"failed"!==r._sendTransport.connectionState&&"disconnected"!==r._sendTransport.connectionState?I.debug("Nothing to in case of socket reconnection with send transport status:%s",null===(t=r._sendTransport)||void 0===t?void 0:t.connectionState):(I.debug("Ws reconnected after network outage. Need to do ICE restarts for send transport."),r.restartIceSendTransport()),!r._recvTransport||"failed"!==r._recvTransport.connectionState&&"disconnected"!==r._recvTransport.connectionState?I.debug("Nothing to in case of socket reconnection with recv transport status:%s",null===(i=r._recvTransport)||void 0===i?void 0:i.connectionState):(I.debug("Ws reconnected after network outage. Need to do ICE restarts for recv transport."),r.restartIceRecvTransport()),e.next=9;break;case 6:return I.debug("Ws connected for first time. Need to go with the regular flow."),e.next=9,r._joinRoom();case 9:case"end":return e.stop()}}),e)})))),this._cignal.on("failed",(function(){})),this._cignal.on("disconnected",(function(){I.debug("ws disconnected!"),r._cignalConnected=!1})),this._cignal.on("close",(function(){r._closed||r._reconnectionInitiated||r.close()})),this._cignal.on("request",function(){var e=(0,s.default)(a.default.mark((function e(t,i,n){var s,c,d,u,l,h,p,m,b,g,v,y,_,w,S;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:I.debug('cignal "request" event [method:%s, data:%o]',t.method,t.data),r._cignalConnected=!0,e.t0=t.method,e.next="newConsumer"===e.t0?5:30;break;case 5:if(r.data.inputParams.consume){e.next=8;break}return n(403,"I do not want to consume"),e.abrupt("break",30);case 8:return s=t.data,c=s.peerId,d=s.producerId,u=s.id,l=s.kind,h=s.rtpParameters,p=s.type,m=s.appData,b=s.producerPaused,e.prev=9,e.next=12,r._recvTransport.consume({id:u,producerId:d,kind:l,rtpParameters:h,streamId:"".concat(c,"-").concat(m.share?"share":"mic-webcam"),appData:E(E({},m),{},{peerId:c})});case 12:g=e.sent,r._consumers.set(g.id,g),g.on("transportclose",(function(){r._consumers.delete(g.id)})),v=f.parseScalabilityMode(g.rtpParameters.encodings[0].scalabilityMode),y=v.spatialLayers,_=v.temporalLayers,w=r._peers.get(c),I.debug("Consumer created for peerId ".concat(c," for kind ").concat(g.kind)),S=E(E({},w),{},(0,o.default)({},m.share?"ss".concat(g.kind):g.kind,{consumerId:g.id,type:p,locallyPaused:!1,remotelyPaused:b,rtpParameters:g.rtpParameters,spatialLayers:y,temporalLayers:_,preferredSpatialLayer:y-1,preferredTemporalLayer:_-1,priority:1,codec:g.rtpParameters.codecs[0].mimeType.split("/")[1],track:g.track,share:m.share})),r._peers.set(c,S),i(),I.debug("Going to emit mic start / videostart"),"audio"===g.kind?m.share?r.emit("ssAudioStart",{peerId:c,audioTrack:g.track,type:"remote"}):r.emit("micStart",{peerId:c,audioTrack:g.track,type:"remote"}):"video"===g.kind&&(m.share?r.emit("ssVideoStart",{peerId:c,videoTrack:g.track,type:"remote"}):r.emit("videoStart",{peerId:c,videoTrack:g.track,type:"remote"})),e.next=29;break;case 25:throw e.prev=25,e.t1=e.catch(9),I.error('"newConsumer" request failed:%o',e.t1),e.t1;case 29:return e.abrupt("break",30);case 30:case"end":return e.stop()}}),e,null,[[9,25]])})));return function(t,r,i){return e.apply(this,arguments)}}()),this._cignal.on("notification",(function(e){switch("activeSpeaker"!==e.method&&I.debug('proto "notification" event [method:%s, data:%o]',e.method,e.data),r._cignalConnected=!0,e.method){case"producerScore":var t=e.data;t.producerId,t.score;break;case"newPeer":var i=e.data;r._peers.set(i.id,E(E({},i),{},{consumers:[]})),r.emit("newPeer",{peerId:i.id,peerName:i.displayName,type:"remote"});break;case"peerClosed":var n=e.data.peerId;r._peers.delete(n),r.emit("peerLeft",{peerId:n});break;case"roomClosed":I.debug("Room closed. No need to reconnect socket"),r.close();break;case"consumerClosed":var a=e.data.consumerId,s=r._consumers.get(a);if(I.debug("Consumer closed for consumerId:%s, type:%s",a,null==s?void 0:s.kind),!s)break;var o=s.appData,c=o.peerId,d=o.share,u=d?"ss".concat(s.kind):s.kind;s.close(),r._consumers.delete(a);var l=r._peers.get(c);I.debug("Peer data before deletion:%O",l),l[u]&&l[u].consumerId===a&&delete l[u],I.debug("Peer data after deletion:%O",l),r._peers.set(c,l),"audio"===u?(I.debug("Going to emit micEnd, consumer closed for audio"),d?r.emit("ssAudioStop",{peerId:c,track:null,type:"remote"}):r.emit("micEnd",{peerId:c,track:null,type:"remote"})):"video"===u&&(I.debug("Going to emit videoEnd, consumer closed for video"),d?r.emit("ssVideoStop",{peerId:c,track:null,type:"remote"}):r.emit("videoEnd",{peerId:c,track:null,type:"remote"}));break;case"consumerPaused":var h=e.data.consumerId,f=r._consumers.get(h);if(!f)break;f.pause();break;case"consumerResumed":var p=e.data.consumerId,m=r._consumers.get(p);if(!m)break;m.resume();break;case"consumerLayersChanged":var b=e.data,g=b.consumerId;if(b.spatialLayer,b.temporalLayer,!r._consumers.get(g))break;break;case"consumerScore":var v=e.data;v.consumerId,v.score;break;case"activeSpeaker":var y=e.data,_=y.peerId,w=y.volume;r._activeSpeaker=e.data,r.emit("activeSpeaker",{peerId:_,volume:w});break;case"peerMuted":var S=e.data.peerId;r.emit("peerMuted",{peerId:S,type:"remote"});break;case"peerUnMuted":var k=e.data.peerId;r.emit("peerUnMuted",{peerId:k,type:"remote"});break;default:I.error('unknown protoo notification.method "%s"',e.method)}}));case 8:case"end":return e.stop()}}),e,this)}))),function(){return z.apply(this,arguments)})},{key:"restartIceSendTransport",value:(q=(0,s.default)(a.default.mark((function e(){var t;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(I.debug("restartIce SendTransport()"),!this._restartIceInProgressSendTransport){e.next=4;break}return I.warn("Restart ice already in progress for send transport! wait 4 completion b4 next request!"),e.abrupt("return");case 4:if(e.prev=4,!this._sendTransport||"failed"!==this._sendTransport.connectionState&&"disconnected"!==this._sendTransport.connectionState){e.next=14;break}return this._restartIceInProgressSendTransport=!0,I.debug("Restarting ICE for send transport"),e.next=10,this._cignal.request("restartIce",{transportId:this._sendTransport.id,peerId:this._peerId});case 10:return t=e.sent,e.next=13,this._sendTransport.restartIce({iceParameters:t});case 13:this._restartIceInProgressSendTransport=!1;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(4),I.error("restartIce SendTransport() | failed:%o",e.t0);case 19:this._reconnectionInitiated=!1;case 20:case"end":return e.stop()}}),e,this,[[4,16]])}))),function(){return q.apply(this,arguments)})},{key:"restartIceRecvTransport",value:(U=(0,s.default)(a.default.mark((function e(){var t;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(I.debug("restartIce RecvTransport()"),!this._restartIceInProgressRecvTransport){e.next=4;break}return I.warn("Restart ice already in progress for recv transport! wait 4 completion b4 next request!"),e.abrupt("return");case 4:if(e.prev=4,!this._recvTransport||"failed"!==this._recvTransport.connectionState&&"disconnected"!==this._recvTransport.connectionState){e.next=14;break}return this._restartIceInProgressRecvTransport=!0,I.debug("Restarting ICE for recv transport"),e.next=10,this._cignal.request("restartIce",{transportId:this._recvTransport.id,peerId:this._peerId});case 10:return t=e.sent,e.next=13,this._recvTransport.restartIce({iceParameters:t});case 13:this._restartIceInProgressRecvTransport=!1;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(4),I.error("restartIce RecvTransport() | failed:%o",e.t0);case 19:this._reconnectionInitiated=!1;case 20:case"end":return e.stop()}}),e,this,[[4,16]])}))),function(){return U.apply(this,arguments)})},{key:"_joinRoom",value:(F=(0,s.default)(a.default.mark((function e(){var t,r,i,n,o,c,d,u,l,h,f,p,m,b,g,v,y,_,w=this;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return I.debug("_joinRoom()"),e.prev=1,e.next=4,this._cignal.request("getRouterRtpCapabilities",{coreNumber:this.data.core});case 4:return t=e.sent,I.debug("Router rtp capabilities created:%O",t),I.debug("Input params are:",this.data.inputParams),e.next=9,this._device.load({routerRtpCapabilities:t});case 9:if(!this.data.inputParams.produce){e.next=19;break}return I.debug("Going to create webrtctransport send"),e.next=13,this._cignal.request("createWebRtcTransport",{forceTcp:this._forceTcp||!1,producing:!0,consuming:!1,sctpCapabilities:this._useDataChannel?this._device.sctpCapabilities:void 0});case 13:r=e.sent,i=r.id,n=r.iceParameters,o=r.iceCandidates,c=r.dtlsParameters,d=r.sctpParameters,I.debug("Transport info is:%O",r),this._sendTransport=this._device.createSendTransport({id:i,iceParameters:n,iceCandidates:o,dtlsParameters:E(E({},c),{},{role:"auto"}),sctpParameters:d,iceServers:[],proprietaryConstraints:O,additionalSettings:{encodedInsertableStreams:this._e2eKey&&e2e.isSupported()}}),this._sendTransport.on("connect",(function(e,t,r){var i=e.iceParameters,n=e.dtlsParameters;w._cignal.request("connectWebRtcTransport",{transportId:w._sendTransport.id,iceParameters:i,dtlsParameters:n}).then(t).catch(r)})),this._sendTransport.on("produce",function(){var e=(0,s.default)(a.default.mark((function e(t,r,i){var n,s,o,c,d;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.kind,s=t.rtpParameters,o=t.appData,e.prev=1,e.next=4,w._cignal.request("produce",{transportId:w._sendTransport.id,kind:n,rtpParameters:s,appData:o});case 4:c=e.sent,d=c.id,r({id:d}),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),i(e.t0);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,r,i){return e.apply(this,arguments)}}());case 19:if(!this.data.inputParams.consume){e.next=28;break}return I.debug("Going to create webrtctransport recv"),e.next=23,this._cignal.request("createWebRtcTransport",{forceTcp:this._forceTcp,producing:!1,consuming:!0,sctpCapabilities:this._useDataChannel?this._device.sctpCapabilities:void 0});case 23:u=e.sent,l=u.id,h=u.iceParameters,f=u.iceCandidates,p=u.dtlsParameters,m=u.sctpParameters,I.debug("Transport info is:%O",u),this._recvTransport=this._device.createRecvTransport({id:l,iceParameters:h,iceCandidates:f,dtlsParameters:E(E({},p),{},{role:"auto"}),sctpParameters:m,iceServers:[],additionalSettings:{encodedInsertableStreams:this._e2eKey&&e2e.isSupported()}}),this._recvTransport.on("connect",(function(e,t,r){var i=e.iceParameters,n=e.dtlsParameters;w._cignal.request("connectWebRtcTransport",{transportId:w._recvTransport.id,iceParameters:i,dtlsParameters:n}).then(t).catch(r)}));case 28:return e.next=30,this._cignal.request("join",{displayName:this.data.inputParams.peerName,device:this._device,rtpCapabilities:this.data.inputParams.consume?this._device.rtpCapabilities:void 0,sctpCapabilities:this._useDataChannel&&this.data.inputParams.consume?this._device.sctpCapabilities:void 0});case 30:b=e.sent,g=b.peers,this.emit("newPeer",{peerId:this.data.inputParams.peerId,peerName:this.data.inputParams.peerName,type:"local"}),this._roomStatus="connected",I.debug("All availablepeers in this room are::%O",g),v=R(g);try{for(v.s();!(y=v.n()).done;)_=y.value,this._peers.set(_.id,E(E({},_),{},{consumers:[]})),I.debug("new peer is:%O",_),this.emit("newPeer",{peerId:_.id,peerName:_.displayName,type:"remote"})}catch(e){v.e(e)}finally{v.f()}this.data.inputParams.produce&&(this.data.inputParams.produceAudio?this.enableMic({deviceId:this.data.inputParams.audioDeviceId?this.data.inputParams.audioDeviceId:null}):I.debug("No need to produce audio!"),(this._device.canProduce("video")||this._externalVideo)&&(this.data.inputParams.produceVideo?this.enableCam({deviceId:this.data.inputParams.videoDeviceId?this.data.inputParams.videoDeviceId:null}):I.debug("No need to produce video!"),this.data.inputParams.share&&this.enableShare({shareAudio:this.data.inputParams.shareAudio,enableSharingLayers:this._enableSharingLayers,shareBitRates:this.data.inputParams.shareBitRates})),this._sendTransport.on("connectionstatechange",(function(e){"connected"===e&&I.debug("Send transport now connected!")}))),e.next=45;break;case 40:e.prev=40,e.t0=e.catch(1),I.error("_joinRoom() failed:%o",e.t0),this.emit("error",{code:"EJR001",text:"Join room request failed!"}),this.close();case 45:case"end":return e.stop()}}),e,this,[[1,40]])}))),function(){return F.apply(this,arguments)})},{key:"enableMic",value:(N=(0,s.default)(a.default.mark((function e(){var t,r,i,n,s,o,c,d,u,l,h,f,p=this,m=arguments;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=m.length>0&&void 0!==m[0]?m[0]:{}).deviceId,i=void 0===r?null:r,n=t.autoGainControl,s=t.noiseSuppression,o=t.echoCancellation,c=t.channelCount,d=t.sampleRate,u=t.forcePCMU,l=t.forcePCMA,I.debug("enableMic()"),this.data.inputParams.produce){e.next=7;break}return I.debug("Produce status is set to false!"),e.abrupt("return",{success:!1,error:!0,code:"REID007",text:"Error while trying to start Mic/Audio. Produce flag need to set to true while joining room in order to enable Mic/Audio."});case 7:if("connected"===this._roomStatus){e.next=12;break}return I.debug("Room status is not connected yet!"),e.abrupt("return",{success:!1,error:!0,code:"REID008",text:"Error while trying to start Mic/Audio as room not in connected status. Current room status:!".concat(this._roomStatus),possibleReasons:"Did you forget to call joinRoom before enabling Mic? OR if you have already initiated the joinRoom process, then Mic will be enabled automatically once room join process completes."});case 12:if(!this._micProducer){e.next=17;break}return I.debug("Mic is already active!"),e.abrupt("return",{success:!1,warning:!0,code:"RWID002",text:"Error while trying to start Mic/Audio. Mic/Audio is already active!"});case 17:if(this._device.canProduce("audio")){e.next=20;break}return I.error("enableMic() | cannot produce audio"),e.abrupt("return",{success:!1,error:!0,code:"REID009",text:"Error while trying to start Mic/Audio. Mic/Audio couldnot be activated due to limitations on this device. If you think this device has a functional Mic and the problem persists even after multiple retries, please contact technical support with the error code."});case 20:if(u&&"boolean"==typeof u&&(this.data.inputParams.forcePCMU=u),l&&"boolean"==typeof l&&(this.data.inputParams.forcePCMA=l),n&&"boolean"==typeof n&&(this.data.inputParams.autoGainControl=n),o&&"boolean"==typeof o&&(this.data.inputParams.echoCancellation=o),s&&"boolean"==typeof s&&(this.data.inputParams.noiseSuppression=s),d&&Number.isInteger(d)&&d<64e3&&d>8e3&&(this.data.inputParams.sampleRate=d),c&&Number.isInteger(c)&&c>0&&c<3&&(this.data.inputParams.channelCount=c),e.prev=27,this._externalVideo){e.next=48;break}if(i?(f=this._deviceList.audioDevices.find((function(e){return e.deviceId===i})))||(I.warn("Selected audio input deviceId:%s not found",i),f=this._deviceList.audioDevices[0]):f=this._deviceList.audioDevices[0],this._mic.device=f,f){e.next=34;break}return I.error("No mic device found! Can't start audio!"),e.abrupt("return",{success:!1,reason:"No mic available for starting audio!"});case 34:return i&&this.data.inputParams.audioDeviceId!==i&&(this.data.inputParams.audioDeviceId=i),I.debug("enableMic() | calling getUserMedia()"),e.prev=36,e.next=39,navigator.mediaDevices.getUserMedia({audio:{deviceId:{ideal:f.deviceId},echoCancellation:this.data.inputParams.echoCancellation,noiseSuppression:this.data.inputParams.noiseSuppression,autoGainControl:this.data.inputParams.autoGainControl,sampleRate:this.data.inputParams.sampleRate,channelCount:this.data.inputParams.channelCount}});case 39:this._micStream=e.sent,h=this._micStream.getAudioTracks()[0],e.next=46;break;case 43:throw e.prev=43,e.t0=e.catch(36),new Error("Error while acquiring mic. Possible issue with audio constraint values",e.t0);case 46:e.next=52;break;case 48:return e.next=50,this._getExternalVideoStream();case 50:this._micStream=e.sent,h=this._micStream.getAudioTracks()[0].clone();case 52:return e.next=54,this._sendTransport.produce({track:h,codecOptions:this.data.inputParams.forcePCMU||this.data.inputParams.forcePCMA?void 0:{opusStereo:!1,opusDtx:!0,opusFec:!0,opusNack:!0},codec:this.data.inputParams.forcePCMU?this._device.rtpCapabilities.codecs.find((function(e){return"audio/pcmu"===e.mimeType.toLowerCase()})):this.data.inputParams.forcePCMA?this._device.rtpCapabilities.codecs.find((function(e){return"audio/pcma"===e.mimeType.toLowerCase()})):void 0});case 54:this._micProducer=e.sent,this._producers.set("audio",{id:this._micProducer.id,paused:this._micProducer.paused,track:this._micProducer.track,rtpParameters:this._micProducer.rtpParameters,codec:this._micProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("micStart",{peerId:this.data.inputParams.peerId,audioTrack:this._micProducer.track,type:"local"}),this._micProducer.on("transportclose",(function(){p._micProducer=null})),this._micProducer.on("trackended",(function(){p.disableMic().catch((function(){}))})),e.next=66;break;case 61:e.prev=61,e.t1=e.catch(27),I.error("enableMic() | failed:%o",e.t1),this.emit("error",{code:"EID002",text:"Error enabling microphone!"}),h&&h.stop();case 66:case"end":return e.stop()}}),e,this,[[27,61],[36,43]])}))),function(){return N.apply(this,arguments)})},{key:"disableMic",value:(B=(0,s.default)(a.default.mark((function e(){return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(I.debug("disableMic()"),this._micStream&&this._micStream.getAudioTracks().forEach((function(e){return e.stop()})),this._micProducer){e.next=4;break}return e.abrupt("return");case 4:return this._micProducer.close(),this._producers.delete("audio"),e.prev=6,e.next=9,this._cignal.request("closeProducer",{producerId:this._micProducer.id});case 9:this.emit("micEnd",{peerId:this.data.inputParams.peerId,audioTrack:null,type:"local"}),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(6),this.emit("error",{code:"EID003",text:"Error disabling microphone!"});case 15:this._micProducer=null;case 16:case"end":return e.stop()}}),e,this,[[6,12]])}))),function(){return B.apply(this,arguments)})},{key:"muteMic",value:(j=(0,s.default)(a.default.mark((function e(){return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return I.debug("muteMic()"),this._micProducer.pause(),e.prev=2,e.next=5,this._cignal.request("pauseProducer",{producerId:this._micProducer.id});case 5:this.emit("peerMuted",{peerId:this.data.inputParams.peerId,type:"local"}),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(2),I.error("muteMic() | failed: %o",e.t0),this.emit("error",{code:"EID004",text:"Error muting local microphone!"});case 12:case"end":return e.stop()}}),e,this,[[2,8]])}))),function(){return j.apply(this,arguments)})},{key:"unmuteMic",value:(L=(0,s.default)(a.default.mark((function e(){return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return I.debug("unmuteMic()"),this._micProducer.resume(),e.prev=2,e.next=5,this._cignal.request("resumeProducer",{producerId:this._micProducer.id});case 5:this.emit("peerUnMuted",{peerId:this.data.inputParams.peerId,type:"local"}),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(2),I.error("unmuteMic() | failed: %o",e.t0),this.emit("error",{code:"EID005",text:"Error unmuting local microphone!"});case 12:case"end":return e.stop()}}),e,this,[[2,8]])}))),function(){return L.apply(this,arguments)})},{key:"enableCam",value:(A=(0,s.default)(a.default.mark((function e(){var t,r,i,n,s,o,c,d,u,l,h,f,p,m,b,g,v,y,_,w=this,S=arguments;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=S.length>0&&void 0!==S[0]?S[0]:{}).deviceId,i=void 0===r?null:r,n=t.videoResolution,s=t.forceVp8,o=t.forceVp9,c=t.forceH264,d=t.h264Profile,u=t.forceFPS,l=t.enableWebcamLayers,h=t.numSimulcastStreams,f=t.videoBitRates,I.debug("enableWebcam()"),this.data.inputParams.produce){e.next=7;break}return I.debug("Produce status is set to false!"),e.abrupt("return",{success:!1,error:!0,code:"REID004",text:"Error while trying to start Camera. Produce flag need to set to true while joining room in order to enable Camera."});case 7:if("connected"===this._roomStatus){e.next=10;break}return I.debug("Room status is not connected yet!"),e.abrupt("return",{success:!1,error:!0,code:"REID005",text:"Error while trying to start Camera as room not in connected status. Current room status:!".concat(this._roomStatus),possibleReasons:"Did you forget to call joinRoom before enabling Camera? OR if you have already initiated the joinRoom process, then Camera will be enabled automatically once room join process completes."});case 10:if(!this._webcamProducer){e.next=13;break}return I.debug("Camera is already active!"),e.abrupt("return",{success:!1,warning:!0,code:"RWID003",text:"Error while trying to start Camera. Camera is already active!"});case 13:if(this._device.canProduce("video")){e.next=16;break}return I.error("enableWebcam() | cannot produce video"),e.abrupt("return",{success:!1,error:!0,code:"REID006",text:"Error while trying to start Camera. Camera couldnot be activated due to limitations on this device. If you think this device has a functional camera and the problem persists even after multiple retries, please contact technical support with the error code."});case 16:if(["hd","vga","qvga"].includes(n)&&(this.data.inputParams.videoResolution=n,this._webcam.resolution=n),s&&"boolean"==typeof s&&(this.data.inputParams.forceVp8=s),o&&"boolean"==typeof o&&(this.data.inputParams.forceVp9=o),c&&"boolean"==typeof c&&(this.data.inputParams.forceH264=c),d&&["high","low"].includes(d.toLowerCase())&&(this.data.inputParams.h264Profile=d),u&&Number.isInteger(u)&&u<65&&u>5&&(this.data.inputParams.forceFPS=25),l&&"boolean"==typeof l&&(this.data.inputParams.enableWebcamLayers=l,this._enableWebcamLayers=l),h&&Number.isInteger(h)&&h<4&&h>0&&(this.data.inputParams.numSimulcastStreams=h,this._numSimulcastStreams=h),Array.isArray(f)&&f.length>=1&&f.length<=3&&f.every((function(e){return Number.isInteger(e)&&e>=75&&e<=800}))?(I.debug("videoBitRates values are correct"),this.data.inputParams.videoBitRates=f):I.warn("videobitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[700,250,75]'"),e.prev=25,this._externalVideo){e.next=41;break}if(i?(m=this._deviceList.videoDevices.find((function(e){return e.deviceId===i})))||(I.warn("Selected deviceId:%s not found",i),m=this._deviceList.videoDevices[0]):m=this._deviceList.videoDevices[0],this._webcam.device=m,b=this._webcam.resolution,m){e.next=33;break}return I.error("No wencam device found! Can't start video!"),e.abrupt("return",{success:!1,reason:"No Webcam available for starting video!"});case 33:return i&&this.data.inputParams.videoDeviceId!==i&&(this.data.inputParams.videoDeviceId=i),I.debug("enableWebcam() | calling getUserMedia()"),e.next=37,navigator.mediaDevices.getUserMedia({video:E(E({deviceId:{ideal:m.deviceId}},D[b]),{},{frameRate:{ideal:this.data.inputParams.forceFPS}})});case 37:this._webCamStream=e.sent,p=this._webCamStream.getVideoTracks()[0],e.next=46;break;case 41:return m={label:"external video"},e.next=44,this._getExternalVideoStream();case 44:this._webCamStream=e.sent,p=this._webCamStream.getVideoTracks()[0].clone();case 46:if(y={videoGoogleStartBitrate:1e3},I.debug("Current device codec options are:%O",this._device.rtpCapabilities.codecs),!this._forceVP8){e.next=54;break}if(v=this._device.rtpCapabilities.codecs.find((function(e){return"video/vp8"===e.mimeType.toLowerCase()}))){e.next=52;break}throw new Error("desired VP8 codec+configuration is not supported");case 52:e.next=67;break;case 54:if(!this._forceH264){e.next=63;break}if("high"===this.data.inputParams.h264Profile?v=this._device.rtpCapabilities.codecs.find((function(e){return"video/h264"===e.mimeType.toLowerCase()&&"4d001f"===e.parameters["profile-level-id"]})):"low"===this.data.inputParams.h264Profile&&(v=this._device.rtpCapabilities.codecs.find((function(e){return"video/h264"===e.mimeType.toLowerCase()&&"42e01f"===e.parameters["profile-level-id"]}))),v){e.next=60;break}throw new Error("desired H264 codec+configuration is not supported");case 60:I.debug("Selected h264 codec is:%O",v);case 61:e.next=67;break;case 63:if(!this._forceVP9){e.next=67;break}if(v=this._device.rtpCapabilities.codecs.find((function(e){return"video/vp9"===e.mimeType.toLowerCase()}))){e.next=67;break}throw new Error("desired VP9 codec+configuration is not supported");case 67:return this._enableWebcamLayers&&(_=this._device.rtpCapabilities.codecs.find((function(e){return"video"===e.kind})),this._forceVP9&&v||"video/vp9"===_.mimeType.toLowerCase()?g=[{maxBitrate:5e6,scalabilityMode:this._webcamScalabilityMode||"L3T3_KEY"}]:(g=[{scaleResolutionDownBy:1,maxBitrate:1e3*this.data.inputParams.videoBitRates[0],scalabilityMode:this._webcamScalabilityMode||"L1T3"}],this._numSimulcastStreams>1&&g.unshift({scaleResolutionDownBy:2,maxBitrate:1e3*this.data.inputParams.videoBitRates[1],scalabilityMode:this._webcamScalabilityMode||"L1T3"}),this._numSimulcastStreams>2&&g.unshift({scaleResolutionDownBy:4,maxBitrate:1e3*this.data.inputParams.videoBitRates[2],scalabilityMode:this._webcamScalabilityMode||"L1T3"}))),e.next=70,this._sendTransport.produce({track:p,encodings:g,codecOptions:y,codec:v});case 70:this._webcamProducer=e.sent,this._producers.set("video",{id:this._webcamProducer.id,deviceLabel:m.label,type:this._getWebcamType(m),paused:this._webcamProducer.paused,track:this._webcamProducer.track,rtpParameters:this._webcamProducer.rtpParameters,codec:this._webcamProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("videoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._webcamProducer.track,type:"local"}),this._webcamProducer.on("transportclose",(function(){w._webcamProducer=null})),this._webcamProducer.on("trackended",(function(){w.disableWebcam().catch((function(){}))})),e.next=82;break;case 77:e.prev=77,e.t0=e.catch(25),I.error("enableWebcam() | failed:%o",e.t0),this.emit("error",{code:"EID011",text:"Enable Webcam failed!"}),p&&p.stop();case 82:case"end":return e.stop()}}),e,this,[[25,77]])}))),function(){return A.apply(this,arguments)})},{key:"disableCam",value:(T=(0,s.default)(a.default.mark((function e(){return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(I.debug("disableWebcam()"),this._webcamProducer){e.next=3;break}return e.abrupt("return");case 3:return this._webcamProducer.close(),this._producers.delete("video"),e.prev=5,e.next=8,this._cignal.request("closeProducer",{producerId:this._webcamProducer.id});case 8:this.emit("videoEnd",{peerId:this.data.inputParams.peerId,videoTrack:null}),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(5),this.emit("error",{code:"EID012",text:"Error while closing server side producer!"});case 14:this._webcamProducer=null;case 15:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(){return T.apply(this,arguments)})},{key:"_updateWebcams",value:(M=(0,s.default)(a.default.mark((function e(){var t,r,i,n,s,o,c;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return I.debug("_updateWebcams()"),this._webcams=new Map,I.debug("_updateWebcams() | calling enumerateDevices()"),e.next=5,navigator.mediaDevices.enumerateDevices();case 5:t=e.sent,r=R(t),e.prev=7,r.s();case 9:if((i=r.n()).done){e.next=16;break}if("videoinput"===(n=i.value).kind){e.next=13;break}return e.abrupt("continue",14);case 13:this._webcams.set(n.deviceId,n);case 14:e.next=9;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(7),r.e(e.t0);case 21:return e.prev=21,r.f(),e.finish(21);case 24:s=Array.from(this._webcams.values()),o=s.length,c=this._webcam.device?this._webcam.device.deviceId:void 0,I.debug("_updateWebcams() [webcams:%o]",s),0===o?this._webcam.device=null:this._webcams.has(c)||(this._webcam.device=s[0]);case 29:case"end":return e.stop()}}),e,this,[[7,18,21,24]])}))),function(){return M.apply(this,arguments)})},{key:"_getExternalVideoStream",value:(P=(0,s.default)(a.default.mark((function e(){var t=this;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._externalVideoStream){e.next=2;break}return e.abrupt("return",this._externalVideoStream);case 2:if(!(this._externalVideo.readyState<3)){e.next=5;break}return e.next=5,new Promise((function(e){return t._externalVideo.addEventListener("canplay",e)}));case 5:if(!this._externalVideo.captureStream){e.next=9;break}this._externalVideoStream=this._externalVideo.captureStream(),e.next=14;break;case 9:if(!this._externalVideo.mozCaptureStream){e.next=13;break}this._externalVideoStream=this._externalVideo.mozCaptureStream(),e.next=14;break;case 13:throw new Error("video.captureStream() not supported");case 14:return e.abrupt("return",this._externalVideoStream);case 15:case"end":return e.stop()}}),e,this)}))),function(){return P.apply(this,arguments)})},{key:"_getWebcamType",value:function(e){return/(back|rear)/i.test(e.label)?(I.debug("_getWebcamType() | it seems to be a back camera"),"back"):(I.debug("_getWebcamType() | it seems to be a front camera"),"front")}},{key:"changeVideoInput",value:(k=(0,s.default)(a.default.mark((function e(t){var r,i,n,s;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.resolution,i=t.deviceId,n=t.fps,!this._webcamProducer){e.next=8;break}return e.next=4,this._changeVideoInput({resolution:r,deviceId:i,fps:n});case 4:return s=e.sent,e.abrupt("return",s);case 8:return I.error("No webcam producer available!"),e.abrupt("return",{success:!1,reason:"You are not sharing your camera yet. Camera Input can be changed to a new camera only when you are sharing an existing camera. "});case 10:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"_changeVideoInput",value:(g=(0,s.default)(a.default.mark((function e(t){var r,i,n,s,o,c;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.resolution,i=t.deviceId,n=t.fps,I.info("_changeVideoInput() | Inside"),r&&["hd","vga","qvga"].includes(r)?this._webcam.resolution=r:I.warn("Invalid video resolution value "),n&&Number.isInteger(n)&&n<65&&n>5?this.data.inputParams.forceFPS=n:I.warn("forceFPS should be a number between 5 to 65, default value is 25 fps."),s=this._deviceList.videoDevices.find((function(e){return i&&e.deviceId===i}))){e.next=8;break}return I.error("The selected deviceId not found!"),e.abrupt("return",{success:!1,reason:"Invalid deviceId!"});case 8:return this._webcam.device=s,e.prev=9,this._webCamStream.getVideoTracks().forEach((function(e){return e.stop()})),this._webCamStream=null,I.debug("changeVideoInput() | calling getUserMedia()"),e.next=15,navigator.mediaDevices.getUserMedia({video:E(E({deviceId:{ideal:s.deviceId}},D[this._webcam.resolution]),{},{frameRate:{ideal:this.data.inputParams.forceFPS}})});case 15:return this._webCamStream=e.sent,o=this._webCamStream.getVideoTracks()[0],I.debug("The new video track is:%O",o),e.next=20,this._webcamProducer.replaceTrack({track:o});case 20:return(c=this._producers.get("video")).deviceLabel=s.label,c.type=this._getWebcamType(s),c.track=this._webcamProducer.track,I.debug("Updated producer values are:%O",c),this._producers.set("video",c),this.emit("videoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._webcamProducer.track,type:"local"}),e.abrupt("return",{success:!0});case 30:return e.prev=30,e.t0=e.catch(9),I.error("Error while changing input:%O",e.t0),e.abrupt("return",{success:!1,reason:"Couldn't change video input",error:e.t0});case 34:case"end":return e.stop()}}),e,this,[[9,30]])}))),function(e){return g.apply(this,arguments)})},{key:"changeAudioInput",value:(b=(0,s.default)(a.default.mark((function e(t){var r,i,n,s,o,c,d;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.autoGainControl,i=t.echoCancellation,n=t.noiseSuppression,s=t.sampleRate,o=t.channelCount,c=t.deviceId,!this._micProducer){e.next=8;break}return e.next=4,this._changeAudioInput({autoGainControl:r,echoCancellation:i,noiseSuppression:n,sampleRate:s,channelCount:o,deviceId:c});case 4:return d=e.sent,e.abrupt("return",d);case 8:return e.abrupt("return",{success:!1,reason:"You are not sharing your mic yet. Mic Input can be changed to a new mic only when you are sharing an existing mic. "});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"_changeAudioInput",value:(l=(0,s.default)(a.default.mark((function e(t){var r,i,n,s,o,c,d,u,l;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.autoGainControl,i=t.echoCancellation,n=t.noiseSuppression,s=t.sampleRate,o=t.channelCount,c=t.deviceId,r&&"boolean"==typeof r&&(this.data.inputParams.autoGainControl=r),i&&"boolean"==typeof i&&(this.data.inputParams.echoCancellation=Boolean(i)),n&&"boolean"==typeof n&&(this.data.inputParams.noiseSuppression=Boolean(n)),s&&Number.isInteger(s)&&s<64e3&&s>8e3&&(this.data.inputParams.sampleRate=s),o&&Number.isInteger(o)&&o>0&&o<3&&(this.data.inputParams.channelCount=o),d=this._deviceList.audioDevices.find((function(e){return c&&e.deviceId===c}))){e.next=9;break}return e.abrupt("return",{success:!1,reason:"Invalid deviceId!"});case 9:return this._mic.device=d,this._micStream&&this._micStream.getAudioTracks().forEach((function(e){return e.stop()})),this._micStream=null,e.prev=12,e.next=15,navigator.mediaDevices.getUserMedia({audio:{deviceId:{ideal:d.deviceId},echoCancellation:this.data.inputParams.echoCancellation,noiseSuppression:this.data.inputParams.noiseSuppression,autoGainControl:this.data.inputParams.autoGainControl,sampleRate:this.data.inputParams.sampleRate,channelCount:this.data.inputParams.channelCount}});case 15:return this._micStream=e.sent,u=this._micStream.getAudioTracks()[0],this._micProducer.replaceTrack({track:u}),(l=this._producers.get("audio")).deviceLabel=d.label,l.track=this._micProducer.track,I.debug("Updated producer values are:%O",l),this._producers.set("audio",l),this.emit("micStart",{peerId:this.data.inputParams.peerId,audioTrack:this._micProducer.track,type:"local"}),e.abrupt("return",{success:!0});case 27:return e.prev=27,e.t0=e.catch(12),I.error("Error while changing input:%O",e.t0),e.abrupt("return",{success:!1,reason:"Couldn't change audio input",err:e.t0});case 31:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e){return l.apply(this,arguments)})},{key:"enableShare",value:(u=(0,s.default)(a.default.mark((function e(){var t,r,i,n,s,o,c,d,u,l,h,f,p,m,b=this,g=arguments;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=g.length>0&&void 0!==g[0]?g[0]:{}).shareAudio,i=void 0!==r&&r,n=t.enableSharingLayers,s=void 0===n||n,o=t.shareBitRates,c=void 0===o?[2500,1250,500]:o,I.debug("enableShare()"),this.data.inputParams.produce){e.next=7;break}return I.debug("Produce status is set to false!"),e.abrupt("return",{success:!1,error:!0,code:"REID003",text:"Error while trying to start screen share. Produce flag need to set to true while joining room in order to enable screen share."});case 7:if("connected"===this._roomStatus){e.next=12;break}return I.debug("Room status is not connected yet!"),e.abrupt("return",{success:!1,error:!0,code:"REID001",text:"Error while trying to start screen share as room not in connected status. Current room status:!".concat(this._roomStatus),possibleReasons:"Did you forget to call joinRoom before enabling screen share? OR if you have already initiated the joinRoom process, then try enabling screen share after some seconds."});case 12:if(!this._shareProducer){e.next=17;break}return I.debug("Screen share is already active!"),e.abrupt("return",{success:!1,warning:!0,code:"RWID001",text:"Error while trying to start screen share. Screen share is already active!"});case 17:if(this._device.canProduce("video")){e.next=20;break}return I.error("enableShare() | cannot produce video"),e.abrupt("return",{success:!1,error:!0,code:"REID002",text:"Error while trying to start screen share. Screen share couldnot be activated due to limitations on this device. If you think this device is capable of screen share and the problem persists even after multiple retries, please contact technical support with the error code."});case 20:return this._enableSharingLayers="boolean"!=typeof s?Boolean(s):s,Array.isArray(c)&&c.length>=1&&c.length<=3&&c.every((function(e){return Number.isInteger(e)&&e>=500&&e<=2500}))?this.data.inputParams.shareBitRates=c:this.data.inputParams.shareBitRates=[2500,1250,500],e.prev=22,I.debug("enableShare() | calling getDisplayMedia()"),e.next=26,navigator.mediaDevices.getDisplayMedia({audio:!!i,video:{displaySurface:"monitor",logicalSurface:!0,cursor:!0,width:{max:1920},height:{max:1080},frameRate:{max:30}}});case 26:if(l=e.sent){e.next=31;break}return I.error("Unable to capture screen."),this.emit("error",{code:"EID013",text:"Error while trying to start screen share. Not able to capture screen!"}),e.abrupt("return");case 31:if(!(u=l.getAudioTracks()[0])){e.next=38;break}return e.next=35,this._sendTransport.produce({track:u,codecOptions:this.data.inputParams.forcePCMU?void 0:{opusStereo:!1,opusDtx:!0,opusFec:!0,opusNack:!0},codec:this.data.inputParams.forcePCMU?this._device.rtpCapabilities.codecs.find((function(e){return"audio/pcmu"===e.mimeType.toLowerCase()})):void 0});case 35:this._shareAudioProducer=e.sent,this._producers.set("ssAudio",{id:this._shareAudioProducer.id,type:"shareAudio",paused:this._shareAudioProducer.paused,track:this._shareAudioProducer.track,rtpParameters:this._shareAudioProducer.rtpParameters,codec:this._shareAudioProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("ssAudioStart",{peerId:this.data.inputParams.peerId,audioTrack:this._shareAudioProducer.track,type:"local"});case 38:if(d=l.getVideoTracks()[0],p={videoGoogleStartBitrate:1e3},!this._forceVP8){e.next=46;break}if(f=this._device.rtpCapabilities.codecs.find((function(e){return"video/vp8"===e.mimeType.toLowerCase()}))){e.next=44;break}throw new Error("desired VP8 codec+configuration is not supported");case 44:e.next=59;break;case 46:if(!this._forceH264){e.next=55;break}if("high"===this.data.inputParams.h264Profile?f=this._device.rtpCapabilities.codecs.find((function(e){return"video/h264"===e.mimeType.toLowerCase()&&"4d001f"===e.parameters["profile-level-id"]})):"low"===this.data.inputParams.h264Profile&&(f=this._device.rtpCapabilities.codecs.find((function(e){return"video/h264"===e.mimeType.toLowerCase()&&"42e01f"===e.parameters["profile-level-id"]}))),f){e.next=52;break}throw new Error("desired H264 codec+configuration is not supported");case 52:I.debug("Selected h264 codec is:%O",f);case 53:e.next=59;break;case 55:if(!this._forceVP9){e.next=59;break}if(f=this._device.rtpCapabilities.codecs.find((function(e){return"video/vp9"===e.mimeType.toLowerCase()}))){e.next=59;break}throw new Error("desired VP9 codec+configuration is not supported");case 59:return this._enableSharingLayers&&(m=this._device.rtpCapabilities.codecs.find((function(e){return"video"===e.kind})),this._forceVP9&&f||"video/vp9"===m.mimeType.toLowerCase()?h=[{maxBitrate:1e3*this.data.inputParams.shareBitRates[0],scalabilityMode:this._sharingScalabilityMode||"L3T3",dtx:!0}]:(h=[{scaleResolutionDownBy:1,maxBitrate:1e3*this.data.inputParams.shareBitRates[0],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}],this._numSimulcastStreams>1&&h.unshift({scaleResolutionDownBy:2,maxBitrate:1e3*this.data.inputParams.shareBitRates[1],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}),this._numSimulcastStreams>2&&h.unshift({scaleResolutionDownBy:4,maxBitrate:1e3*this.data.inputParams.shareBitRates[2],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}))),e.next=62,this._sendTransport.produce({track:d,encodings:h,codecOptions:p,codec:f,appData:{share:!0}});case 62:this._shareProducer=e.sent,this._producers.set("ssVideo",{id:this._shareProducer.id,type:"shareVideo",paused:this._shareProducer.paused,track:this._shareProducer.track,rtpParameters:this._shareProducer.rtpParameters,codec:this._shareProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("ssVideoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._shareProducer.track,type:"local"}),this._shareProducer.on("transportclose",(function(){b._shareProducer=null})),this._shareProducer.on("trackended",(function(){b.disableShare().catch((function(){}))})),e.next=74;break;case 69:e.prev=69,e.t0=e.catch(22),I.error("enableShare() | failed:%o",e.t0),"NotAllowedError"!==e.t0.name&&this.emit("error",{code:"EID014",text:"Error while trying to start screen share. Error is: ".concat(e.t0,"!")}),d&&d.stop();case 74:case"end":return e.stop()}}),e,this,[[22,69]])}))),function(){return u.apply(this,arguments)})},{key:"disableShare",value:(n=(0,s.default)(a.default.mark((function e(){return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(I.debug("disableShare()"),this._shareProducer){e.next=5;break}return I.warn("Screen share doesn't seem to be on!"),this.emit("error",{code:"EID017",text:"Error while trying to stop screen share. Is the screen share on!"}),e.abrupt("return");case 5:if(this._shareProducer.close(),!this._shareAudioProducer){e.next=17;break}return this._shareAudioProducer.close(),e.prev=8,e.next=11,this._cignal.request("closeProducer",{producerId:this._shareAudioProducer.id});case 11:this.emit("ssAudioStop",{peerId:this.data.inputParams.peerId,videoTrack:null,type:"local"}),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(8),this.emit("error",{code:"EID015",text:"Error while trying to stop screen share audio. Error is: ".concat(e.t0,"!")});case 17:return e.prev=17,e.next=20,this._cignal.request("closeProducer",{producerId:this._shareProducer.id});case 20:this.emit("ssVideoStop",{peerId:this.data.inputParams.peerId,videoTrack:null,type:"local"}),e.next=26;break;case 23:e.prev=23,e.t1=e.catch(17),this.emit("error",{code:"EID016",text:"Error while trying to stop screen share video. Error is: ".concat(e.t1,"!")});case 26:this._shareAudioProducer=null,this._shareProducer=null;case 28:case"end":return e.stop()}}),e,this,[[8,14],[17,23]])}))),function(){return n.apply(this,arguments)})}],[{key:"listDevices",value:(i=(0,s.default)(a.default.mark((function e(){var t;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!C){e.next=3;break}return I.info("Device list already exists:%O",C),e.abrupt("return",{success:!0,deviceList:C});case 3:return e.next=5,(0,S.loadAllAvailableDevices)();case 5:if(!(t=e.sent).success){e.next=11;break}return C=t.deviceList,e.abrupt("return",{success:!0,deviceList:t.deviceList});case 11:return e.abrupt("return",{success:!1,reason:t.reason});case 12:case"end":return e.stop()}}),e)}))),function(){return i.apply(this,arguments)})},{key:"joinRoom",value:(r=(0,s.default)(a.default.mark((function e(){var r,i,n,s,o,c,d,u,l,h,f,m,b,g,S,k,R,P,M,E,x,T,C,D,O,A,L,j,B,N,F,U,q,z,V,G,W,H,K,$,J,Y,X,Z,Q,ee,te,re,ie,ne,ae,se,oe,ce,de,ue,le,he,fe,pe,me,be,ge,ve,ye,_e=arguments;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=(r=_e.length>0&&void 0!==_e[0]?_e[0]:{}).sessionToken,n=r.roomId,s=r.peerId,o=r.peerName,c=r.produce,d=void 0===c||c,u=r.produceAudio,l=void 0===u||u,h=r.produceVideo,f=void 0===h||h,m=r.consume,b=void 0===m||m,g=r.videoResolution,S=void 0===g?"hd":g,k=r.forceVp8,R=void 0!==k&&k,P=r.forceVp9,M=void 0!==P&&P,E=r.forceH264,x=void 0!==E&&E,T=r.h264Profile,C=void 0===T?"high":T,D=r.forcePCMU,O=void 0!==D&&D,A=r.forcePCMA,L=void 0!==A&&A,j=r.forceFPS,B=void 0===j?25:j,N=r.enableWebcamLayers,F=void 0===N||N,U=r.numSimulcastStreams,q=void 0===U?3:U,z=r.autoGainControl,V=void 0===z||z,G=r.echoCancellation,W=void 0===G||G,H=r.noiseSuppression,K=void 0===H||H,$=r.sampleRate,J=void 0===$?44e3:$,Y=r.channelCount,X=void 0===Y?1:Y,Z=r.videoBitRates,Q=void 0===Z?[700,250,75]:Z,ee=r.share,te=void 0!==ee&&ee,re=r.shareAudio,ie=void 0!==re&&re,ne=r.enableSharingLayers,ae=void 0===ne||ne,se=r.shareBitRates,oe=void 0===se?[2500,1250,500]:se,ce=r.audioDeviceId,de=void 0===ce?null:ce,ue=r.videoDeviceId,le=void 0===ue?null:ue,i){e.next=3;break}throw new Error("Session token is required to join the room.");case 3:return["hd","vga","qvga"].includes(S)||(I.warn("Invalid video resolution value. setting it to default value of 'hd' "),S="hd"),"boolean"!=typeof d&&(I.warn("Produe should either be true or false"),d=Boolean(d)),"boolean"!=typeof l&&(I.warn("ProduceAudio should either be true or false"),l=Boolean(l)),"boolean"!=typeof f&&(I.warn("ProduceVideo should either be true or false"),f=Boolean(f)),"boolean"!=typeof b&&(I.warn("Consume should either be true or false"),b=Boolean(b)),"boolean"!=typeof R&&(I.warn("forceVp8 should either be true or false"),R=Boolean(R)),"boolean"!=typeof M&&(I.warn("forceVp9 should either be true or false"),M=Boolean(M)),"boolean"!=typeof x&&(I.warn("forceH264 should either be true or false"),x=Boolean(x)),["high","low"].includes(C.toLowerCase())||(I.warn("h264Profile should either be 'high' or 'low'"),C="high"),(!Number.isInteger(B)||Number.isInteger(B)&&(B>65||B<5))&&(I.warn("forceFPS should be a number between 5 to 65, default value is 25 fps."),B=25),"boolean"!=typeof F&&(I.warn("enableWebcamLayers should either be true or false"),F=Boolean(F)),(!Number.isInteger(q)||Number.isInteger(q)&&(q>3||q<1))&&(I.warn("numSimulcastStreams should be a number between 1 to 3, default value is 3."),q=3),Array.isArray(Q)&&Q.length>=1&&Q.length<=3&&Q.every((function(e){return Number.isInteger(e)&&e>=75&&e<=800}))?I.debug("videoBitRates values are correct"):(I.warn("videobitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[75,250,75]'"),Q=[75,75,75]),"boolean"!=typeof O&&(I.warn("forcePCMU should either be true or false"),O=Boolean(O)),"boolean"!=typeof L&&(I.warn("forcePCMA should either be true or false"),L=Boolean(L)),"boolean"!=typeof V&&(I.warn("autoGainControl should either be true or false"),V=Boolean(V)),"boolean"!=typeof W&&(I.warn("echoCancellation should either be true or false"),W=Boolean(W)),"boolean"!=typeof K&&(I.warn("noiseSuppression should either be true or false"),K=Boolean(K)),(!Number.isInteger(J)||Number.isInteger(J)&&(J>64e3||J<8e3))&&(I.warn("sampleRate should be a number between 8000 to 64000, default value is 44000 Khz."),J=44e3),(!Number.isInteger(X)||Number.isInteger(X)&&(X>2||X<1))&&(I.warn("sampleRate should be a number between 1 to 2, default value is 1, which is a mono audio."),X=1),"boolean"!=typeof te&&(I.warn("share should either be true or false"),te=Boolean(te)),"boolean"!=typeof ie&&(I.warn("shareAudio should either be true or false"),ie=Boolean(ie)),"boolean"!=typeof ae&&(I.warn("enableSharingLayers should either be true or false"),ae=Boolean(ae)),Array.isArray(oe)&&oe.length>=1&&oe.length<=3&&oe.every((function(e){return Number.isInteger(e)&&e>=500&&e<=2500}))?I.debug("shareBitRates values are correct"):(I.warn("sharebitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[2500,1250,500]'"),oe=[2500,1250,500]),e.prev=27,I.info("session token:%s",i),s||(s=(0,y.uuidv4)()),n||(n=(0,v.getRandomInt)()),o||(o=(0,w.default)()),he=p.default.parse(window.navigator.userAgent),fe=he.browser.name,pe=he.browser.version,me=he.os.name,be={name:s,participantType:"moderator",browserName:fe,browserVersion:pe,os:me},I.info("browser details are:%O",he),ge={sessionToken:i,roomId:n,peerId:s,consumerReplicas:0,producer:d,consumer:b,participantData:be},ve={},I.debug("Received input parameters are:%O",ge),e.next=43,(0,_.getVidScaleUrl)(ge);case 43:if(!((ye=e.sent).success&&ye.wsUrl&&ye.core)){e.next=49;break}ve.url=ye.wsUrl,ve.core=ye.core,e.next=51;break;case 49:return I.warn("Vidscale returned success as false. with error:%O",ye),e.abrupt("return",ye);case 51:return I.debug("VidScale url is:",ve.url),e.abrupt("return",new t({peerId:s,roomId:n,peerName:o,produce:d,produceAudio:l,produceVideo:f,consume:b,videoResolution:S,forceVp8:R,forceVp9:M,forceH264:x,h264Profile:C,forceFPS:B,forcePCMU:O,forcePCMA:L,enableWebcamLayers:F,numSimulcastStreams:q,autoGainControl:V,echoCancellation:W,noiseSuppression:K,sampleRate:J,channelCount:X,videoBitRates:Q,share:te,shareAudio:ie,enableSharingLayers:ae,shareBitRates:oe,outputData:ve,audioDeviceId:de,videoDeviceId:le}));case 55:throw e.prev=55,e.t0=e.catch(27),I.error("Failed to join room:",e.t0.message),e.t0;case 59:case"end":return e.stop()}}),e,null,[[27,55]])}))),function(){return r.apply(this,arguments)})}]);var r,i,n,u,l,b,g,k,P,M,T,A,L,j,B,N,F,U,q,z,V,G,W,H}(b.EventEmitter)},{"./Logger":4,"./socket":5,"./utils/chooseMedia":12,"./utils/constants":13,"./utils/getRandomInt":14,"./utils/getVidScaleUrl":16,"./utils/randomName":18,"./utils/uuidv4":20,"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/defineProperty":27,"@babel/runtime/helpers/getPrototypeOf":28,"@babel/runtime/helpers/inherits":29,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/helpers/possibleConstructorReturn":33,"@babel/runtime/helpers/typeof":38,"@babel/runtime/regenerator":39,bowser:61,events:91,"mediasoup-client":232}],4:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault"),n=i(e("@babel/runtime/helpers/classCallCheck")),a=i(e("@babel/runtime/helpers/createClass")),s=e("debug"),o="VidScale-js",c=function(){return(0,a.default)((function e(t){(0,n.default)(this,e),t?(this._debug=s("".concat(o,":").concat(t)),this._info=s("".concat(o,":INFO:").concat(t)),this._warn=s("".concat(o,":WARN:").concat(t)),this._error=s("".concat(o,":ERROR:").concat(t))):(this._debug=s(o),this._info=s("".concat(o,":INFO")),this._warn=s("".concat(o,":WARN")),this._error=s("".concat(o,":ERROR"))),this._debug.log=console.info.bind(console),this._info.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}),[{key:"debug",get:function(){return this._debug}},{key:"info",get:function(){return this._info}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}])}();t.exports=c},{"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/interopRequireDefault":30,debug:104}],5:[function(e,t,r){"use strict";var i=e("./lib/Peer"),n=e("./lib/transports/SocketTransport"),a=e("./lib/transports/WebSocketTransport");r.Peer=i,r.SocketTransport=n,r.WebSocketTransport=a},{"./lib/Peer":8,"./lib/transports/SocketTransport":9,"./lib/transports/WebSocketTransport":10}],6:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault"),n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator")),s=i(e("@babel/runtime/helpers/classCallCheck")),o=i(e("@babel/runtime/helpers/createClass")),c=i(e("@babel/runtime/helpers/possibleConstructorReturn")),d=i(e("@babel/runtime/helpers/getPrototypeOf")),u=i(e("@babel/runtime/helpers/inherits"));function l(e,t,r){return t=(0,d.default)(t),(0,c.default)(e,h()?Reflect.construct(t,r||[],(0,d.default)(e).constructor):t.apply(e,r))}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(h=function(){return!!e})()}var f=e("events").EventEmitter,p=e("../../Logger"),m=function(e){function t(e){var r;return(0,s.default)(this,t),(r=l(this,t)).setMaxListeners(1/0),r._logger=e||new p("EnhancedEventEmitter"),r}return(0,u.default)(t,e),(0,o.default)(t,[{key:"safeEmit",value:function(e){try{for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];this.emit.apply(this,[e].concat(r))}catch(t){this._logger.error("safeEmit() | event listener threw an error [event:%s]:%o",e,t)}}},{key:"safeEmitAsPromise",value:(r=(0,a.default)(n.default.mark((function e(t){var r,i,a,s=this,o=arguments;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=o.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=o[a];return e.abrupt("return",new Promise((function(e,r){s.safeEmit.apply(s,[t].concat(i,[e,r]))})));case 2:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})}]);var r}(f);t.exports=m},{"../../Logger":4,"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/getPrototypeOf":28,"@babel/runtime/helpers/inherits":29,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/helpers/possibleConstructorReturn":33,"@babel/runtime/regenerator":39,events:91}],7:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault"),n=i(e("@babel/runtime/helpers/typeof")),a=i(e("@babel/runtime/helpers/classCallCheck")),s=i(e("@babel/runtime/helpers/createClass")),o=e("../../Logger"),c=e("./utils").generateRandomNumber,d=new o("Message"),u=function(){return(0,s.default)((function e(){(0,a.default)(this,e)}),null,[{key:"parse",value:function(e){var t,r={};try{t=JSON.parse(e)}catch(e){return void d.error("parse() | invalid JSON: %s",e)}if("object"===(0,n.default)(t)&&!Array.isArray(t)){if(t.request){if(r.request=!0,"string"!=typeof t.method)return void d.error("parse() | missing/invalid method field");if("number"!=typeof t.id)return void d.error("parse() | missing/invalid id field");r.id=t.id,r.method=t.method,r.data=t.data||{}}else if(t.response){if(r.response=!0,"number"!=typeof t.id)return void d.error("parse() | missing/invalid id field");r.id=t.id,t.ok?(r.ok=!0,r.data=t.data||{}):(r.ok=!1,r.errorCode=t.errorCode,r.errorReason=t.errorReason)}else{if(!t.notification)return void d.error("parse() | missing request/response field");if(r.notification=!0,"string"!=typeof t.method)return void d.error("parse() | missing/invalid method field");r.method=t.method,r.data=t.data||{}}return r}d.error("parse() | not an object")}},{key:"createRequest",value:function(e,t){return{request:!0,id:c(),method:e,data:t||{}}}},{key:"createSuccessResponse",value:function(e,t){return{response:!0,id:e.id,ok:!0,data:t||{}}}},{key:"createErrorResponse",value:function(e,t,r){return{response:!0,id:e.id,ok:!1,errorCode:t,errorReason:r}}},{key:"createNotification",value:function(e,t){return{notification:!0,method:e,data:t||{}}}}])}();t.exports=u},{"../../Logger":4,"./utils":11,"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/helpers/typeof":38}],8:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault"),n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator")),s=i(e("@babel/runtime/helpers/classCallCheck")),o=i(e("@babel/runtime/helpers/createClass")),c=i(e("@babel/runtime/helpers/possibleConstructorReturn")),d=i(e("@babel/runtime/helpers/getPrototypeOf")),u=i(e("@babel/runtime/helpers/inherits"));function l(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return h(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}function f(e,t,r){return t=(0,d.default)(t),(0,c.default)(e,p()?Reflect.construct(t,r||[],(0,d.default)(e).constructor):t.apply(e,r))}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(p=function(){return!!e})()}var m=e("../../Logger"),b=e("./EnhancedEventEmitter"),g=e("./Message"),v=new m("Peer"),y=function(e){function t(e){var r;return(0,s.default)(this,t),r=f(this,t,[v]),v.debug("constructor()"),r._closed=!1,r._transport=e,r._connected=!1,r._data={},r._sents=new Map,r._handleTransport(),r}return(0,u.default)(t,e),(0,o.default)(t,[{key:"closed",get:function(){return this._closed}},{key:"connected",get:function(){return this._connected}},{key:"data",get:function(){return this._data},set:function(e){throw new Error("cannot override data object")}},{key:"close",value:function(){if(!this._closed){v.debug("close()"),this._closed=!0,this._connected=!1,this._transport.close();var e,t=l(this._sents.values());try{for(t.s();!(e=t.n()).done;){e.value.close()}}catch(e){t.e(e)}finally{t.f()}this.safeEmit("close")}}},{key:"request",value:(i=(0,a.default)(n.default.mark((function e(t){var r,i,a=this,s=arguments;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=s.length>1&&void 0!==s[1]?s[1]:void 0,i=g.createRequest(t,r),this._logger.debug("request() [method:%s, id:%s]",t,i.id),e.next=5,this._transport.send(i);case 5:return e.abrupt("return",new Promise((function(e,t){var r=1500*(15+.1*a._sents.size),n={id:i.id,method:i.method,resolve:function(t){a._sents.delete(i.id)&&(clearTimeout(n.timer),e(t))},reject:function(e){a._sents.delete(i.id)&&(clearTimeout(n.timer),t(e))},timer:setTimeout((function(){a._sents.delete(i.id)&&t(new Error("request timeout"))}),r),close:function(){clearTimeout(n.timer),t(new Error("peer closed"))}};a._sents.set(i.id,n)})));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"notify",value:(r=(0,a.default)(n.default.mark((function e(t){var r,i,a=arguments;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:void 0,i=g.createNotification(t,r),this._logger.debug("notify() [method:%s]",t),e.next=5,this._transport.send(i);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_handleTransport",value:function(){var e=this;if(this._transport.closed)return this._closed=!0,void setTimeout((function(){e._closed||(e._connected=!1,e.safeEmit("close"))}));this._transport.on("open",(function(){e._closed||(v.debug('emit "open"'),e._connected=!0,e.safeEmit("open"))})),this._transport.on("disconnected",(function(){e._closed||(v.debug('emit "disconnected"'),e._connected=!1,e.safeEmit("disconnected"))})),this._transport.on("failed",(function(t){e._closed||(v.debug('emit "failed" [currentAttempt:%s]',t),e._connected=!1,e.safeEmit("failed",t))})),this._transport.on("close",(function(){e._closed||(e._closed=!0,v.debug('emit "close"'),e._connected=!1,e.safeEmit("close"))})),this._transport.on("message",(function(t){t.request?e._handleRequest(t):t.response?e._handleResponse(t):t.notification&&e._handleNotification(t)}))}},{key:"_handleRequest",value:function(e){var t=this;try{this.emit("request",e,(function(r){var i=g.createSuccessResponse(e,r);t._transport.send(i).catch((function(){}))}),(function(r,i){r instanceof Error?(i=r.message,r=500):"number"==typeof r&&i instanceof Error&&(i=i.message);var n=g.createErrorResponse(e,r,i);t._transport.send(n).catch((function(){}))}))}catch(t){var r=g.createErrorResponse(e,500,String(t));this._transport.send(r).catch((function(){}))}}},{key:"_handleResponse",value:function(e){var t=this._sents.get(e.id);if(t)if(e.ok)t.resolve(e.data);else{var r=new Error(e.errorReason);r.code=e.errorCode,t.reject(r)}else v.error("received response does not match any sent request [id:%s]",e.id)}},{key:"_handleNotification",value:function(e){this.safeEmit("notification",e)}}]);var r,i}(b);t.exports=y},{"../../Logger":4,"./EnhancedEventEmitter":6,"./Message":7,"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/getPrototypeOf":28,"@babel/runtime/helpers/inherits":29,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/helpers/possibleConstructorReturn":33,"@babel/runtime/regenerator":39}],9:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault"),n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator")),s=i(e("@babel/runtime/helpers/classCallCheck")),o=i(e("@babel/runtime/helpers/createClass")),c=i(e("@babel/runtime/helpers/possibleConstructorReturn")),d=i(e("@babel/runtime/helpers/getPrototypeOf")),u=i(e("@babel/runtime/helpers/inherits"));function l(e,t,r){return t=(0,d.default)(t),(0,c.default)(e,h()?Reflect.construct(t,r||[],(0,d.default)(e).constructor):t.apply(e,r))}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(h=function(){return!!e})()}var f=e("socket.io-client"),p=e("../utils").sleep,m=e("../../../Logger"),b=e("../EnhancedEventEmitter"),g=e("../Message"),v=new m("WebSocketTransport"),y=function(e){function t(e,r){var i;return(0,s.default)(this,t),i=l(this,t,[v]),v.debug("constructor() [url:%s, options:%o]",e,r),i._closed=!1,i._url=e,i._connected=!1,i._params=r||{},i._socket=null,i._createSocket(),i}return(0,u.default)(t,e),(0,o.default)(t,[{key:"closed",get:function(){return this._closed}},{key:"close",value:function(){if(!this._closed){v.debug("close()"),this._closed=!0,this.safeEmit("close");try{this._socket.disconnect()}catch(e){v.error("close() | error closing the WebSocket: %o",e)}}}},{key:"send",value:(r=(0,a.default)(n.default.mark((function e(t){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._closed){e.next=2;break}throw new Error("transport closed");case 2:e.prev=2,this._socket.send(JSON.stringify(t)),e.next=10;break;case 6:throw e.prev=6,e.t0=e.catch(2),v.warn("send() failed:%o",e.t0),e.t0;case 10:case"end":return e.stop()}}),e,this,[[2,6]])}))),function(e){return r.apply(this,arguments)})},{key:"_createSocket",value:function(){var e=this;if(!this._url)throw new Error("Cannot create socket without a valid connection url");var t=f(this._url,{rejectUnauthorized:!1});t.on("connect",(function(){e._connected?v.debug("Socket already connected!"):(v.debug("connected to socket"),e._connected=!0,e.safeEmit("open"))})),t.on("disconnect",(0,a.default)(n.default.mark((function t(){return n.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(v.error("socket disconnected!"),e._connected=!1,e.safeEmit("disconnected"),!e._closed){t.next=7;break}v.debug("No need to reconnect for roomClient close!"),t.next=16;break;case 7:if(!(e._reconnectionCounter>240)){t.next=10;break}return v.debug("Reconnection not needed if user disconnection for more than 2 minutes, reconnection counter:",e._reconnectionCounter),t.abrupt("return");case 10:return e._socket.close(),e._socket=null,e._createSocket(),e._reconnectionCounter+=1,t.next=16,p(500);case 16:case"end":return t.stop()}}),t)})))),t.on("reconnect",(function(){v.debug("socket reconnected after disconnect"),e.safeEmit("reconnect")})),t.on("connect_error",(function(t){v.error("socket connect error",t),e._connected=!1})),t.on("error",(function(t){v.error("Socket error",t),e._connected=!1,e.safeEmit("failed")})),t.on("message",(function(t){if(!e._closed){var r=g.parse(t);r&&(0!==e.listenerCount("message")?e.safeEmit("message",r):v.error('no listeners for WebSocket "message" event, ignoring received message'))}})),this._socket=t}}]);var r}(b);t.exports=y},{"../../../Logger":4,"../EnhancedEventEmitter":6,"../Message":7,"../utils":11,"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/getPrototypeOf":28,"@babel/runtime/helpers/inherits":29,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/helpers/possibleConstructorReturn":33,"@babel/runtime/regenerator":39,"socket.io-client":298}],10:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault"),n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator")),s=i(e("@babel/runtime/helpers/classCallCheck")),o=i(e("@babel/runtime/helpers/createClass")),c=i(e("@babel/runtime/helpers/possibleConstructorReturn")),d=i(e("@babel/runtime/helpers/getPrototypeOf")),u=i(e("@babel/runtime/helpers/inherits")),l=i(e("@babel/runtime/helpers/defineProperty"));function h(e,t,r){return t=(0,d.default)(t),(0,c.default)(e,f()?Reflect.construct(t,r||[],(0,d.default)(e).constructor):t.apply(e,r))}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(f=function(){return!!e})()}var p=e("../EnhancedEventEmitter"),m=e("../utils").sleep,b=new(e("../../../Logger"))("WebsocketTransport"),g=function(e){function t(e,r){var i;return(0,s.default)(this,t),i=h(this,t,[b]),(0,l.default)(i,"createAndUpdateSocket",function(){var e=(0,a.default)(n.default.mark((function e(t){var r,a,s,o,c;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.connectionType,a=void 0===r?null:r,b.info("Room close status:%s",i._closed),s=i,!i._closed){e.next=6;break}return b.info("Websocket already closed!"),e.abrupt("return");case 6:if(i._url){e.next=9;break}return b.warn("url not available!"),e.abrupt("return");case 9:o=null===a?"".concat(i._url,"&connectionType=","landing"):"".concat(i._url,"&connectionType=").concat(a),b.debug("the url is:%s",o),i._ws=new WebSocket(o),c=0,b.debug("websocketHelper createAndUpdateSocket created a new websocket"),b.debug("websocketHelper createAndUpdateSocket:%s",i._ws.readyState);case 15:if(1===i._ws.readyState||!i._socketShouldReconnect){e.next=30;break}if(3!==i._ws.readyState){e.next=22;break}return b.debug("websocketHelper createAndUpdateSocket"),e.next=20,m(2e3);case 20:i._ws=new WebSocket(o),b.debug("websocketHelper createAndUpdateSocket newly created websocket state:%s",i._ws.readyState);case 22:return e.next=24,m(500);case 24:if(!(++c>250)){e.next=28;break}return b.error("No of retries limit to connect with server exhausted!"),e.abrupt("break",30);case 28:e.next=15;break;case 30:1===i._ws.readyState&&b.debug("updated the websocket with ready state -".concat(i._ws.readyState)),i.safeEmit("connected"),b.debug("updating the websocket to redux store with ready state -".concat(i._ws.readyState)),i._ws.onopen=function(){i._closed||(b.debug("Websocket open"),i.safeEmit("open"))},i._isConnected=!0,i._ws.onmessage=function(e){if(!i._closed){var t=JSON.parse(e.data);switch(t.id){case"ping":i._lastTimerId&&clearTimeout(i._lastTimerId);var r=i;i._lastTimerId=setTimeout((function(){r._isConnected=!1,this._roomJoined?r.close(4104,"In call connections close as server is unreachable for last 5 seconds!"):r.close(4103,"Landing page socket close by client as server not reachable for a couple of seconds!"),r._socketShouldReconnect&&(r._closed=!1,r.createAndUpdateSocket({connectionType:"inCall"}))}),22e3);i._ws.send(JSON.stringify({id:"pong"}));break;case"invalidToken":b.debug("Session token invalid!"),i._socketShouldReconnect=!1,i.safeEmit("invalidToken",t);break;case"alreadyActive":i.safeEmit("alreadyActive",t);break;case"passwordDisabled":i.safeEmit("passwordDisabled",t);break;case"notify":i.safeEmit("notify",t.data);break;case"remotePeerJoin":i.safeEmit("roomStartedP2p",t);break;case"userError":i.safeEmit("userError",t);break;case"validationAlert":i.safeEmit("validationError",t);break;case"joinStatusOnLanding":i.safeEmit("defaultJoinStatus",t);break;default:i.safeEmit("message",t)}}},i._ws.onclose=function(e){s._closed||(b.warn('WebSocket "close" event [wasClean:%s, code:%s, reason:"%s"]',e.wasClean,e.code,e.reason),4503===e.code||4504===e.code?(b.error("Socket closed with reason",e.reason),s._closed=!0):4500!==e.code&&(b.debug("trying to reconnect:%s",e.code),s._closed=!1,i._roomJoined?(b.debug("Trying to join after a network reset while in a meeting"),s.createAndUpdateSocket({connectionType:"inCall"})):(b.debug("Trying to join after a network reset while on the landing page"),s.createAndUpdateSocket({connectionType:null})),clearTimeout(s._lastTimerId)),i._url=null,b.info("The websocket closed status is:%s",s._closed),s.safeEmit("close",{code:e.code,reason:e.reason}))};case 37:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),i._closed=!1,i._url=e,i._ws=null,i._socketShouldReconnect=r,i._isConnected=!1,i._lastTimerId=null,i._roomJoined=!1,b.info("Request received to instantiate websocket transport! with url :%s",e),i.createAndUpdateSocket({connectionType:null}),i}return(0,u.default)(t,e),(0,o.default)(t,[{key:"connectionStatus",get:function(){return this._isConnected}},{key:"close",value:function(e,t){if(!this._closed){b.info("close()"),this._closed=!0,this.safeEmit("close",{code:e,reason:t});try{this._ws.onopen=null,this._ws.onclose=null,this._ws.onerror=null,this._ws.onmessage=null,clearTimeout(this._lastTimerId),e&&t?this._ws.close(e,t):this._ws.close()}catch(e){b.error("close() | error closing the WebSocket: %o",e)}}}},{key:"send",value:(r=(0,a.default)(n.default.mark((function e(t){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._closed){e.next=3;break}return b.error("Transport closed or not yet ready. Try again later!"),e.abrupt("return");case 3:e.prev=3,this._ws.send(JSON.stringify(t)),e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(3),b.warn("send() failed:%o",e.t0),e.t0;case 11:case"end":return e.stop()}}),e,this,[[3,7]])}))),function(e){return r.apply(this,arguments)})}]);var r}(p);t.exports=g},{"../../../Logger":4,"../EnhancedEventEmitter":6,"../utils":11,"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/defineProperty":27,"@babel/runtime/helpers/getPrototypeOf":28,"@babel/runtime/helpers/inherits":29,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/helpers/possibleConstructorReturn":33,"@babel/runtime/regenerator":39}],11:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault"),n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator"));r.generateRandomNumber=function(){return Math.round(1e7*Math.random())},r.sleep=function(){var e=(0,a.default)(n.default.mark((function e(t){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){return setTimeout((function(){return e()}),t)})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()},{"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/regenerator":39}],12:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.updatedDeviceList=r.loadAllAvailableDevices=r.getDeviceId=r.chooseMediaLabelVideo=r.chooseMediaLabelAudioOutput=r.chooseMediaLabelAudio=r.chooseMediaLabel=void 0;var n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator")),s=new(i(e("../Logger")).default)("device-manager"),o=(r.chooseMediaLabel=function(){var e=(0,a.default)(n.default.mark((function e(){var t,r;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],r=[],e.abrupt("return",navigator.mediaDevices.enumerateDevices().then((function(e){var i=void 0!==e.find((function(e){return"videoinput"===e.kind})),n=void 0!==e.find((function(e){return"audioinput"===e.kind}));return new Promise((function(e,a){navigator.mediaDevices.getUserMedia({audio:n,video:i}).then((function(i){navigator.mediaDevices.enumerateDevices().then((function(n){n.forEach((function(e){"audioinput"===e.kind&&("videoinput"===e.kind?(t.push(e.label),r.push(e.label)):r.push(e.label))})),i.getTracks().forEach((function(e){e.stop()})),r.length>0&&(t.length>0?e({videoLabels:t,audioLabels:r}):e({audioLabels:r}))}))})).catch((function(t){console.log(t.name+": "+t.message),e({error:t.name,reason:t.message})}))}))})).catch((function(e){console.log(e.name+": "+e.message)})));case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),r.chooseMediaLabelAudio=function(){var e=(0,a.default)(n.default.mark((function e(){var t;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.abrupt("return",navigator.mediaDevices.enumerateDevices().then((function(e){var r=void 0!==e.find((function(e){return"audioinput"===e.kind}));return new Promise((function(e,i){navigator.mediaDevices.getUserMedia({audio:r}).then((function(r){navigator.mediaDevices.enumerateDevices().then((function(i){i.forEach((function(e,r){if("audioinput"===e.kind){var i=e.label||"Mic ".concat(Number(r)+1);t.push({label:i,deviceId:e.deviceId})}})),r.getTracks().forEach((function(e){e.stop()})),e({audioDevices:t})}))})).catch((function(t){console.log(t.name+": "+t.message),e({error:t.name,reason:t.message})}))}))})).catch((function(e){console.log(e.name+": "+e.message)})));case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()),c=r.chooseMediaLabelAudioOutput=function(){var e=(0,a.default)(n.default.mark((function e(){var t;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.abrupt("return",navigator.mediaDevices.enumerateDevices().then((function(e){var r=void 0!==e.find((function(e){return"audiooutput"===e.kind}));return new Promise((function(e,i){navigator.mediaDevices.getUserMedia({audio:r}).then((function(r){navigator.mediaDevices.enumerateDevices().then((function(i){i.forEach((function(e,r){if("audiooutput"===e.kind){var i=e.label||"Speaker ".concat(Number(r)+1);t.push({label:i,deviceId:e.deviceId})}})),r.getTracks().forEach((function(e){e.stop()})),e({audioDevicesOutput:t})}))})).catch((function(t){console.log(t.name+": "+t.message),e({error:t.name,reason:t.message})}))}))})).catch((function(e){console.log(e.name+": "+e.message)})));case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),d=r.chooseMediaLabelVideo=function(){var e=(0,a.default)(n.default.mark((function e(){var t;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.abrupt("return",navigator.mediaDevices.enumerateDevices().then((function(e){var r=void 0!==e.find((function(e){return"videoinput"===e.kind}));return new Promise((function(e,i){navigator.mediaDevices.getUserMedia({video:r}).then((function(r){navigator.mediaDevices.enumerateDevices().then((function(i){i.forEach((function(e,r){if("videoinput"===e.kind){var i=e.label||"Camera ".concat(Number(r)+1);t.push({label:i,deviceId:e.deviceId})}})),r.getTracks().forEach((function(e){e.stop()})),e({videoDevices:t})}))})).catch((function(t){console.log(t.name+": "+t.message),e({error:t.name,reason:t.message})}))}))})).catch((function(e){console.log(e.name+": "+e.message)})));case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();r.getDeviceId=function(e){return new Promise((function(t){s.info("chooseMedia label->:%s",e),navigator.mediaDevices.enumerateDevices().then((function(r){r.forEach((function(r){r.label===e&&t(r.deviceId)})),r[0].label||t({error:"noLabel",reason:"Device label names not found!"})})).catch((function(e){s.error("err.name:%O ",e.message),t({error:e.name,reason:e.message})}))}))},r.updatedDeviceList=function(){var e=(0,a.default)(n.default.mark((function e(){var t,r,i;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],r=[],i=[],e.abrupt("return",new Promise((function(e,n){navigator.mediaDevices.enumerateDevices().then((function(n){n.forEach((function(e,n){if("audioinput"===e.kind){var a=e.label||"Mic ".concat(Number(n)+1);r.push({label:a,deviceId:e.deviceId})}if("videoinput"===e.kind){var s=e.label||"Camera ".concat(Number(n)+1);t.push({label:s,deviceId:e.deviceId})}if("audiooutput"===e.kind){var o=e.label||"Speaker ".concat(Number(n)+1);i.push({label:o,deviceId:e.deviceId})}})),e({audioDevices:r,audioDevicesOutput:i,videoDevices:t})}))})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),r.loadAllAvailableDevices=function(){var e=(0,a.default)(n.default.mark((function e(){var t,r,i,a,s,u;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={videoDevices:[],audioDevices:[],audioOutputDevices:[]},e.next=3,d();case 3:if(r=e.sent,i=null,!r.error){e.next=21;break}e.t0=r.error,e.next="TypeError"===e.t0?9:"AbortError"===e.t0?10:"NotAllowedError"===e.t0?12:"NotFoundError"===e.t0?14:"NotReadableError"===e.t0?16:18;break;case 9:return e.abrupt("break",18);case 10:return i="".concat(r.error," : ").concat(r.reason,"!! Your Camera is currently being used !! If you wish to join the room with video, please close the other tab / browser wherever it is being used and refresh this page!!"),e.abrupt("break",18);case 12:return i="".concat(r.error," : ").concat(r.reason,'!! You have denied the access to your Camera!! If you wish to join the room with video, please allow the camera access by clicking on the camera icon in the address bar Or by going to " chrome://settings/content#media-stream-mic " link in your chrome.'),e.abrupt("break",18);case 14:return i="".concat(r.error," : ").concat(r.reason,"!! No Camera could be found!! If you have a camera or microphone in your computer but it is not able to detect them, please refresh your browser again or restart the browser after closing all the opened tabs."),e.abrupt("break",18);case 16:return i="".concat(r.error," : ").concat(r.reason,"!! If you have a camera in your computer but it is not able to detect it as it may have been used by some other browser / tab, please refresh your browser again after closing the tab using the camera or restart the browser after closing all the opened tabs."),e.abrupt("break",18);case 18:return e.abrupt("return",{success:!1,reason:{code:"EDV01",type:"DeviceError",text:i}});case 21:r.videoDevices&&r.videoDevices.length>0&&(t.videoDevices=r.videoDevices);case 22:return e.next=24,o();case 24:if(a=e.sent,s=null,!a.error){e.next=39;break}e.t1=a.error,e.next="NotAllowedError"===e.t1?30:"NotFoundError"===e.t1?32:"NotReadableError"===e.t1?34:36;break;case 30:return s="".concat(a.error," : ").concat(a.reason,'!! You have denied the access to your Mic!! If you wish to join the room with video, please allow the camera access by clicking on the camera icon in the address bar Or by going to " chrome://settings/content#media-stream-mic " link in your chrome.'),e.abrupt("break",36);case 32:return s="".concat(a.error," : ").concat(a.reason,"!! No Microphone could be found!! If you have a camera or microphone in your computer but it is not able to detect them, please refresh your browser again or restart the browser after closing all the opened tabs."),e.abrupt("break",36);case 34:return s="".concat(a.error," : ").concat(a.reason,"!! A hardware error occured at the OS OR browser Or Webpage level. If you have a microphone in your computer but it is not able to detect them, please refresh your browser again or restart the browser after closing all the opened tabs."),e.abrupt("break",36);case 36:return e.abrupt("return",{success:!1,reason:{code:"EDA01",type:"DeviceError",text:s}});case 39:a.audioDevices&&a.audioDevices.length>0&&(t.audioDevices=a.audioDevices);case 40:return e.next=42,c();case 42:if(!(u=e.sent).error){e.next=47;break}return e.abrupt("return",{success:!1,reason:{code:"EDAO01",type:"DeviceError",text:"Some error occured while accessing your speaker. Please try again again after some time."}});case 47:u.audioDevicesOutput&&u.audioDevicesOutput.length>0&&(t.audioOutputDevices=u.audioDevicesOutput);case 48:return e.abrupt("return",{success:!0,deviceList:t});case 49:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},{"../Logger":4,"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/regenerator":39}],13:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r._security=r.USER_TYPE_REGULAR=r.USER_TYPE_PRESENTER=r.USER_TYPE_MODERATOR=r.USER_TYPE_BOT=r.USER_TYPE_ADMIN=r.TOTAL_RECORDING_SPACE_AVAILABLE=r.STREAM_TYPE_SCREEN_VIDEO=r.STREAM_TYPE_SCREEN_AUDIO=r.STREAM_TYPE_CAM_VIDEO=r.STREAM_TYPE_CAM_AUDIO=r.STAGE=r.RTMPSTREAMANDRECORD=r.RTMPSTREAM=r.ROOM_STATUS_ENUM_OCUPIED=r.ROOM_STATUS_ENUM_FREE=r.ROOM_LEAVE_ONLY=r.ROOM_LEAVE_AND_CLOSE=r.ROOM_CLOSE_TYPE_CLIENT=r.ROOMTYPE_P2P=r.ROOMTYPE_EVENT=r.ROOMTYPE_CONFERENCING=r.RECORD=r.PROCESS=r.PARTICIPANT=r.MSG_TYPE_PUBLIC=r.MSG_TYPE_PRIVATE=r.MSG_SENDER_TYPE_VIEWER=r.MSG_SENDER_TYPE_PRESENTER=r.MSG_SENDER_TYPE_MODERATOR=r.MSG_SENDER_TYPE_EVERYBODY=r.MSG_DIRECTION_SEND=r.MSG_DIRECTION_RECV=r.MERGEA=r.MERGE=r.CLOUD_DO=r.CLOUD_AWS=r.BACK_STAGE=r.AMERGEA=r.AMERGE=void 0;r._security={roomType:{P2P:"p2p",CONFERENCING:"conferencing"},baseURL:"",vidScaleURL:"autoscalerv1.videoedge.io/api/vidScale/allocateResources",autoscalerURL:"autoscaler.samvyo.com",dashboardURL:"https://api.samvyo.com/api/callStats/verifySessionToken"},r.MSG_SENDER_TYPE_PRESENTER="participant",r.MSG_SENDER_TYPE_VIEWER="viewer",r.MSG_SENDER_TYPE_EVERYBODY="everybody",r.MSG_SENDER_TYPE_MODERATOR="moderator",r.MSG_TYPE_PRIVATE="private",r.MSG_TYPE_PUBLIC="public",r.MSG_DIRECTION_SEND="send",r.MSG_DIRECTION_RECV="recv",r.STREAM_TYPE_CAM_AUDIO="cam-audio",r.STREAM_TYPE_CAM_VIDEO="cam-video",r.STREAM_TYPE_SCREEN_AUDIO="screen-audio",r.STREAM_TYPE_SCREEN_VIDEO="screen-video",r.ROOM_STATUS_ENUM_FREE="free",r.ROOM_STATUS_ENUM_OCUPIED="occupied",r.ROOM_LEAVE_ONLY="leaveRoomNew",r.ROOM_LEAVE_AND_CLOSE="leaveAndCloseRoom",r.TOTAL_RECORDING_SPACE_AVAILABLE=256,r.USER_TYPE_ADMIN="admin",r.USER_TYPE_MODERATOR="moderator",r.USER_TYPE_PRESENTER="presenter",r.PARTICIPANT="participant",r.USER_TYPE_REGULAR="r",r.USER_TYPE_BOT="b",r.ROOMTYPE_P2P="p2p",r.ROOMTYPE_CONFERENCING="conferencing",r.ROOMTYPE_EVENT="event",r.ROOM_CLOSE_TYPE_CLIENT="client",r.CLOUD_AWS="aws",r.CLOUD_DO="do",r.STAGE="Stage",r.BACK_STAGE="Back-Stage",r.RECORD="record",r.RTMPSTREAM="rtmpStream",r.RTMPSTREAMANDRECORD="rtmpStreamAndRecord",r.PROCESS="process",r.MERGE="mergedAV",r.MERGEA="mergedA",r.AMERGE="AmergedAV",r.AMERGEA="AmergedA"},{}],14:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getRandomInt=void 0;r.getRandomInt=function(){return Math.floor(1e10*Math.random())}},{}],15:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.VIDEO_ONLY_CONSTRAINTS=r.SCREEN_VIDEO_SIMULCAST_ENCODINGS=r.GENERAL_SCREENSHARE_CONSTRAINTS=r.GENERAL_AUDIO_VIDEO_CONSTRAINTS=r.GENERAL_AUDIO_ONLY_CONSTRAINTS=r.CAM_VIDEO_SIMULCAST_RECEIVE_MEDIUM=r.CAM_VIDEO_SIMULCAST_RECEIVE_LOW=r.CAM_VIDEO_SIMULCAST_ENCODINGS=r.AUDIO_VIDEO_CONSTRAINTS=r.AUDIO_ONLY_CONSTRAINTS=void 0;r.GENERAL_AUDIO_VIDEO_CONSTRAINTS={audio:!0,video:{width:{min:320,ideal:1280,max:1280},height:{min:240,ideal:720,max:720},aspectRatio:1.777777778,frameRate:{min:15,max:30}}},r.GENERAL_SCREENSHARE_CONSTRAINTS={audio:!1,video:{displaySurface:"monitor",logicalSurface:!0,cursor:!0,width:{max:1920},height:{max:1080},frameRate:{max:30}}},r.GENERAL_AUDIO_ONLY_CONSTRAINTS={audio:!0,video:!1},r.AUDIO_ONLY_CONSTRAINTS={audio:{deviceId:{exact:void 0}},video:!1},r.VIDEO_ONLY_CONSTRAINTS={audio:!1,video:{deviceId:{exact:void 0},width:{min:320,ideal:1280,max:1280},height:{min:240,ideal:720,max:720},aspectRatio:1.777777778,frameRate:{min:15,max:30}}},r.AUDIO_VIDEO_CONSTRAINTS={audio:{deviceId:{exact:void 0}},video:{deviceId:{exact:void 0},width:{min:320,ideal:1280,max:1280},height:{min:240,ideal:720,max:720},aspectRatio:1.777777778,frameRate:{min:15,max:30}}},r.CAM_VIDEO_SIMULCAST_ENCODINGS=[{maxBitrate:5e5,scaleResolutionDownBy:4,scalabilityMode:"L1T3"},{maxBitrate:1e6,scaleResolutionDownBy:2,scalabilityMode:"L1T3"},{maxBitrate:5e6,scaleResolutionDownBy:1,scalabilityMode:"L1T3"}],r.SCREEN_VIDEO_SIMULCAST_ENCODINGS=[{dtx:!0,maxBitrate:15e5},{dtx:!0,maxBitrate:6e6}],r.CAM_VIDEO_SIMULCAST_RECEIVE_LOW={spatialLayer:0,temporalLayer:0},r.CAM_VIDEO_SIMULCAST_RECEIVE_MEDIUM={spatialLayer:1,temporalLayer:1}},{}],16:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.getVidScaleUrl=function(e){return c.apply(this,arguments)};var n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator")),s=i(e("axios/dist/browser/axios.cjs")),o=i(e("./constants"));new(i(e("../Logger")).default)("vidscale-url");function c(){return(c=(0,a.default)(n.default.mark((function e(t){var r,i,a,s,o,c,u,l,h,f,p;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.sessionToken,i=t.roomId,a=t.peerId,s=t.consumerReplicas,o=t.producer,c=void 0===o||o,u=t.consumer,l=void 0===u||u,h=t.participantData,e.next=3,d({sessionToken:r,roomId:i,peerId:a,producer:c,consumer:l,participantData:h});case 3:if(!(f=e.sent).success){e.next=8;break}return e.abrupt("return",{success:!0,wsUrl:"wss://".concat(f.data.url,"/?roomId=").concat(i,"&peerId=").concat(a,"&consumerReplicas=").concat(s),roomUrl:"https://".concat(f.data.url),core:f.data.core});case 8:return p={success:!1,errorText:f.data.reason,errorCode:f.data.code},e.abrupt("return",p);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var d=function(){var e=(0,a.default)(n.default.mark((function e(t){var r,i,a,c,d,u,l;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.roomId,i=t.peerId,a=t.producer,c=t.consumer,d=t.sessionToken,u=t.participantData,e.next=3,s.default.post("".concat(o.default._security.vidScaleURL),{roomId:r,peerId:i,producer:a,consumer:c,sessionToken:d,participantData:u});case 3:return l=e.sent,e.abrupt("return",new Promise((function(e){try{e(l.data)}catch(e){}})));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()},{"../Logger":4,"./constants":13,"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/regenerator":39,"axios/dist/browser/axios.cjs":58}],17:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.SocketQueue=void 0;var n=i(e("@babel/runtime/helpers/classCallCheck")),a=i(e("@babel/runtime/helpers/createClass"));r.SocketQueue=function(){return(0,a.default)((function e(){(0,n.default)(this,e),this.queue=new Map}),[{key:"push",value:function(e,t){this.queue.set(e,t)}},{key:"get",value:function(e){return this.queue.get(e)}},{key:"remove",value:function(e){this.queue.delete(e)}}])}()},{"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/interopRequireDefault":30}],18:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/typeof");Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(){return n.random("en")};var n=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=i(e)&&"function"!=typeof e)return{default:e};var r=a(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&{}.hasOwnProperty.call(e,o)){var c=s?Object.getOwnPropertyDescriptor(e,o):null;c&&(c.get||c.set)?Object.defineProperty(n,o,c):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}(e("pokemon"));function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(a=function(e){return e?r:t})(e)}},{"@babel/runtime/helpers/typeof":38,pokemon:255}],19:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.sleep=void 0;var n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator"));r.sleep=function(){var e=(0,a.default)(n.default.mark((function e(t){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){return setTimeout((function(){return e()}),t)})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()},{"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/regenerator":39}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.uuidv4=void 0;r.uuidv4=function(){return"111-111-1111".replace(/[018]/g,(function(){return(15&crypto.getRandomValues(new Uint8Array(1))[0]).toString(16)}))}},{}],21:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ALLOWED_QUALITIES=void 0,r.isValidOutputQualities=function(e){if(!Array.isArray(e))return!1;return e.every((function(e){return i.has(e)}))};var i=r.ALLOWED_QUALITIES=new Set(["240p","360p","480p","720p","1080p","1440p","2160p"])},{}],22:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.allowedTypes=void 0,r.verifyFiles=function(e){return l.apply(this,arguments)};var n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator"));function s(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return o(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){c=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw a}}}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i}var c=new(e("../Logger"))("utils-verifyFiles"),d=r.allowedTypes=["mp4"];function u(e,t){try{return new URL(e).pathname.split(".").pop().toLowerCase()===t.toLowerCase()}catch(e){return!1}}function l(){return(l=(0,a.default)(n.default.mark((function e(t){var r,i,a,o,l;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c.info("The input files are:%o, length:%s",t,t.length),!(t.length>0)){e.next=28;break}c.info("Files array length is:%s",t.length),r=s(t),e.prev=4,r.s();case 6:if((i=r.n()).done){e.next=17;break}if(a=i.value,o=a.type,l=a.url,c.info("The file detais are type:%s, url:%s",o,l),d.includes(o)){e.next=12;break}return console.warn('Type "'.concat(o,'" is not allowed.')),e.abrupt("return",{success:!1,reason:'Type "'.concat(o,'" is not allowed.')});case 12:if(u(l,o)){e.next=15;break}return console.warn("Extension mismatch for ".concat(l,"; expected .").concat(o)),e.abrupt("return",{success:!1,reason:"Extension mismatch for ".concat(l,"; expected .").concat(o)});case 15:e.next=6;break;case 17:e.next=22;break;case 19:e.prev=19,e.t0=e.catch(4),r.e(e.t0);case 22:return e.prev=22,r.f(),e.finish(22);case 25:return e.abrupt("return",{success:!0});case 28:return e.abrupt("return",{success:!1,reason:"There are no files for processing!"});case 29:case"end":return e.stop()}}),e,null,[[4,19,22,25]])})))).apply(this,arguments)}},{"../Logger":4,"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/regenerator":39}],23:[function(e,t,r){t.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},t.exports.__esModule=!0,t.exports.default=t.exports},{}],24:[function(e,t,r){function i(e,t,r,i,n,a,s){try{var o=e[a](s),c=o.value}catch(e){return void r(e)}o.done?t(c):Promise.resolve(c).then(i,n)}t.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function o(e){i(s,n,a,o,c,"next",e)}function c(e){i(s,n,a,o,c,"throw",e)}o(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports},{}],25:[function(e,t,r){t.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},{}],26:[function(e,t,r){var i=e("./toPropertyKey.js");function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}t.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},t.exports.__esModule=!0,t.exports.default=t.exports},{"./toPropertyKey.js":37}],27:[function(e,t,r){var i=e("./toPropertyKey.js");t.exports=function(e,t,r){return(t=i(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},t.exports.__esModule=!0,t.exports.default=t.exports},{"./toPropertyKey.js":37}],28:[function(e,t,r){function i(e){return t.exports=i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},t.exports.__esModule=!0,t.exports.default=t.exports,i(e)}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports},{}],29:[function(e,t,r){var i=e("./setPrototypeOf.js");t.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t)},t.exports.__esModule=!0,t.exports.default=t.exports},{"./setPrototypeOf.js":35}],30:[function(e,t,r){t.exports=function(e){return e&&e.__esModule?e:{default:e}},t.exports.__esModule=!0,t.exports.default=t.exports},{}],31:[function(e,t,r){var i=e("./objectWithoutPropertiesLoose.js");t.exports=function(e,t){if(null==e)return{};var r,n,a=i(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a},t.exports.__esModule=!0,t.exports.default=t.exports},{"./objectWithoutPropertiesLoose.js":32}],32:[function(e,t,r){t.exports=function(e,t){if(null==e)return{};var r={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.includes(i))continue;r[i]=e[i]}return r},t.exports.__esModule=!0,t.exports.default=t.exports},{}],33:[function(e,t,r){var i=e("./typeof.js").default,n=e("./assertThisInitialized.js");t.exports=function(e,t){if(t&&("object"==i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return n(e)},t.exports.__esModule=!0,t.exports.default=t.exports},{"./assertThisInitialized.js":23,"./typeof.js":38}],34:[function(e,t,r){var i=e("./typeof.js").default;function n(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */t.exports=n=function(){return r},t.exports.__esModule=!0,t.exports.default=t.exports;var e,r={},a=Object.prototype,s=a.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},d=c.iterator||"@@iterator",u=c.asyncIterator||"@@asyncIterator",l=c.toStringTag||"@@toStringTag";function h(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,r){return e[t]=r}}function f(e,t,r,i){var n=t&&t.prototype instanceof _?t:_,a=Object.create(n.prototype),s=new O(i||[]);return o(a,"_invoke",{value:T(e,r,s)}),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}r.wrap=f;var m="suspendedStart",b="suspendedYield",g="executing",v="completed",y={};function _(){}function w(){}function S(){}var k={};h(k,d,(function(){return this}));var R=Object.getPrototypeOf,P=R&&R(R(A([])));P&&P!==a&&s.call(P,d)&&(k=P);var M=S.prototype=_.prototype=Object.create(k);function E(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){function r(n,a,o,c){var d=p(e[n],e,a);if("throw"!==d.type){var u=d.arg,l=u.value;return l&&"object"==i(l)&&s.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,o,c)}),(function(e){r("throw",e,o,c)})):t.resolve(l).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,c)}))}c(d.arg)}var n;o(this,"_invoke",{value:function(e,i){function a(){return new t((function(t,n){r(e,i,t,n)}))}return n=n?n.then(a,a):a()}})}function T(t,r,i){var n=m;return function(a,s){if(n===g)throw Error("Generator is already running");if(n===v){if("throw"===a)throw s;return{value:e,done:!0}}for(i.method=a,i.arg=s;;){var o=i.delegate;if(o){var c=C(o,i);if(c){if(c===y)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(n===m)throw n=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n=g;var d=p(t,r,i);if("normal"===d.type){if(n=i.done?v:b,d.arg===y)continue;return{value:d.arg,done:i.done}}"throw"===d.type&&(n=v,i.method="throw",i.arg=d.arg)}}}function C(t,r){var i=r.method,n=t.iterator[i];if(n===e)return r.delegate=null,"throw"===i&&t.iterator.return&&(r.method="return",r.arg=e,C(t,r),"throw"===r.method)||"return"!==i&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+i+"' method")),y;var a=p(n,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var s=a.arg;return s?s.done?(r[t.resultName]=s.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function A(t){if(t||""===t){var r=t[d];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function r(){for(;++n<t.length;)if(s.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(i(t)+" is not iterable")}return w.prototype=S,o(M,"constructor",{value:S,configurable:!0}),o(S,"constructor",{value:w,configurable:!0}),w.displayName=h(S,l,"GeneratorFunction"),r.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,h(e,l,"GeneratorFunction")),e.prototype=Object.create(M),e},r.awrap=function(e){return{__await:e}},E(x.prototype),h(x.prototype,u,(function(){return this})),r.AsyncIterator=x,r.async=function(e,t,i,n,a){void 0===a&&(a=Promise);var s=new x(f(e,t,i,n),a);return r.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(M),h(M,l,"Generator"),h(M,d,(function(){return this})),h(M,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var t=Object(e),r=[];for(var i in t)r.push(i);return r.reverse(),function e(){for(;r.length;){var i=r.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},r.values=A,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(D),!t)for(var r in this)"t"===r.charAt(0)&&s.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(i,n){return o.type="throw",o.arg=t,r.next=i,n&&(r.method="next",r.arg=e),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],o=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=s.call(a,"catchLoc"),d=s.call(a,"finallyLoc");if(c&&d){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!d)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&s.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var n=i;break}}n&&("break"===e||"continue"===e)&&n.tryLoc<=t&&t<=n.finallyLoc&&(n=null);var a=n?n.completion:{};return a.type=e,a.arg=t,n?(this.method="next",this.next=n.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),D(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var i=r.completion;if("throw"===i.type){var n=i.arg;D(r)}return n}}throw Error("illegal catch attempt")},delegateYield:function(t,r,i){return this.delegate={iterator:A(t),resultName:r,nextLoc:i},"next"===this.method&&(this.arg=e),y}},r}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports},{"./typeof.js":38}],35:[function(e,t,r){function i(e,r){return t.exports=i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},t.exports.__esModule=!0,t.exports.default=t.exports,i(e,r)}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports},{}],36:[function(e,t,r){var i=e("./typeof.js").default;t.exports=function(e,t){if("object"!=i(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},t.exports.__esModule=!0,t.exports.default=t.exports},{"./typeof.js":38}],37:[function(e,t,r){var i=e("./typeof.js").default,n=e("./toPrimitive.js");t.exports=function(e){var t=n(e,"string");return"symbol"==i(t)?t:t+""},t.exports.__esModule=!0,t.exports.default=t.exports},{"./toPrimitive.js":36,"./typeof.js":38}],38:[function(e,t,r){function i(e){return t.exports=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},t.exports.__esModule=!0,t.exports.default=t.exports,i(e)}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports},{}],39:[function(e,t,r){var i=e("../helpers/regeneratorRuntime")();t.exports=i;try{regeneratorRuntime=i}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}},{"../helpers/regeneratorRuntime":34}],40:[function(e,t,r){function i(e){if(e)return function(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}(e)}r.Emitter=i,i.prototype.on=i.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},i.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},i.prototype.off=i.prototype.removeListener=i.prototype.removeAllListeners=i.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,i=this._callbacks["$"+e];if(!i)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var n=0;n<i.length;n++)if((r=i[n])===t||r.fn===t){i.splice(n,1);break}return 0===i.length&&delete this._callbacks["$"+e],this},i.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(r){i=0;for(var n=(r=r.slice(0)).length;i<n;++i)r[i].apply(this,t)}return this},i.prototype.emitReserved=i.prototype.emit,i.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},i.prototype.hasListeners=function(e){return!!this.listeners(e).length}},{}],41:[function(e,t,r){var i=r;i.bignum=e("bn.js"),i.define=e("./asn1/api").define,i.base=e("./asn1/base"),i.constants=e("./asn1/constants"),i.decoders=e("./asn1/decoders"),i.encoders=e("./asn1/encoders")},{"./asn1/api":42,"./asn1/base":44,"./asn1/constants":48,"./asn1/decoders":50,"./asn1/encoders":53,"bn.js":55}],42:[function(e,t,r){var i=e("../asn1"),n=e("inherits");function a(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new a(e,t)},a.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return n(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},a.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(i.decoders[e])),this.decoders[e]},a.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},a.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(i.encoders[e])),this.encoders[e]},a.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":41,inherits:174,vm:316}],43:[function(e,t,r){var i=e("inherits"),n=e("../base").Reporter,a=e("buffer").Buffer;function s(e,t){n.call(this,t),a.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function o(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return e instanceof o||(e=new o(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=a.byteLength(e);else{if(!a.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}i(s,n),r.DecoderBuffer=s,s.prototype.save=function(){return{offset:this.offset,reporter:n.prototype.save.call(this)}},s.prototype.restore=function(e){var t=new s(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,n.prototype.restore.call(this,e.reporter),t},s.prototype.isEmpty=function(){return this.offset===this.length},s.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},s.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new s(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},s.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=o,o.prototype.join=function(e,t){return e||(e=new a(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):a.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e}},{"../base":44,buffer:94,inherits:174}],44:[function(e,t,r){var i=r;i.Reporter=e("./reporter").Reporter,i.DecoderBuffer=e("./buffer").DecoderBuffer,i.EncoderBuffer=e("./buffer").EncoderBuffer,i.Node=e("./node")},{"./buffer":43,"./node":45,"./reporter":46}],45:[function(e,t,r){var i=e("../base").Reporter,n=e("../base").EncoderBuffer,a=e("../base").DecoderBuffer,s=e("minimalistic-assert"),o=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],c=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(o);function d(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=d;var u=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];d.prototype.clone=function(){var e=this._baseState,t={};u.forEach((function(r){t[r]=e[r]}));var r=new this.constructor(t.parent);return r._baseState=t,r},d.prototype._wrap=function(){var e=this._baseState;c.forEach((function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},d.prototype._init=function(e){var t=this._baseState;s(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),s.equal(t.children.length,1,"Root node can have only one child")},d.prototype._useArgs=function(e){var t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(s(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(s(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);var i=e[r];t[i]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){d.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),o.forEach((function(e){d.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return s(null===t.tag),t.tag=e,this._useArgs(r),this}})),d.prototype.use=function(e){s(e);var t=this._baseState;return s(null===t.use),t.use=e,this},d.prototype.optional=function(){return this._baseState.optional=!0,this},d.prototype.def=function(e){var t=this._baseState;return s(null===t.default),t.default=e,t.optional=!0,this},d.prototype.explicit=function(e){var t=this._baseState;return s(null===t.explicit&&null===t.implicit),t.explicit=e,this},d.prototype.implicit=function(e){var t=this._baseState;return s(null===t.explicit&&null===t.implicit),t.implicit=e,this},d.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},d.prototype.key=function(e){var t=this._baseState;return s(null===t.key),t.key=e,this},d.prototype.any=function(){return this._baseState.any=!0,this},d.prototype.choice=function(e){var t=this._baseState;return s(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},d.prototype.contains=function(e){var t=this._baseState;return s(null===t.use),t.contains=e,this},d.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var i,n=r.default,s=!0,o=null;if(null!==r.key&&(o=e.enterKey(r.key)),r.optional){var c=null;if(null!==r.explicit?c=r.explicit:null!==r.implicit?c=r.implicit:null!==r.tag&&(c=r.tag),null!==c||r.any){if(s=this._peekTag(e,c,r.any),e.isError(s))return s}else{var d=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),s=!0}catch(e){s=!1}e.restore(d)}}if(r.obj&&s&&(i=e.enterObject()),s){if(null!==r.explicit){var u=this._decodeTag(e,r.explicit);if(e.isError(u))return u;e=u}var l=e.offset;if(null===r.use&&null===r.choice){if(r.any)d=e.save();var h=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(h))return h;r.any?n=e.raw(d):e=h}if(t&&t.track&&null!==r.tag&&t.track(e.path(),l,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),r.any||(n=null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t)),e.isError(n))return n;if(r.any||null!==r.choice||null===r.children||r.children.forEach((function(r){r._decode(e,t)})),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var f=new a(n);n=this._getUse(r.contains,e._reporterState.obj)._decode(f,t)}}return r.obj&&s&&(n=e.leaveObject(i)),null===r.key||null===n&&!0!==s?null!==o&&e.exitKey(o):e.leaveKey(o,r.key,n),n},d.prototype._decodeGeneric=function(e,t,r){var i=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,i.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&i.args?this._decodeObjid(t,i.args[0],i.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,i.args&&i.args[0],r):null!==i.use?this._getUse(i.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},d.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),s(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},d.prototype._decodeChoice=function(e,t){var r=this._baseState,i=null,n=!1;return Object.keys(r.choice).some((function(a){var s=e.save(),o=r.choice[a];try{var c=o._decode(e,t);if(e.isError(c))return!1;i={type:a,value:c},n=!0}catch(t){return e.restore(s),!1}return!0}),this),n?i:e.error("Choice not matched")},d.prototype._createEncoderBuffer=function(e){return new n(e,this.reporter)},d.prototype._encode=function(e,t,r){var i=this._baseState;if(null===i.default||i.default!==e){var n=this._encodeValue(e,t,r);if(void 0!==n&&!this._skipDefault(n,t,r))return n}},d.prototype._encodeValue=function(e,t,r){var n=this._baseState;if(null===n.parent)return n.children[0]._encode(e,t||new i);var a=null;if(this.reporter=t,n.optional&&void 0===e){if(null===n.default)return;e=n.default}var s=null,o=!1;if(n.any)a=this._createEncoderBuffer(e);else if(n.choice)a=this._encodeChoice(e,t);else if(n.contains)s=this._getUse(n.contains,r)._encode(e,t),o=!0;else if(n.children)s=n.children.map((function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var i=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var n=r._encode(e[r._baseState.key],t,e);return t.leaveKey(i),n}),this).filter((function(e){return e})),s=this._createEncoderBuffer(s);else if("seqof"===n.tag||"setof"===n.tag){if(!n.args||1!==n.args.length)return t.error("Too many args for : "+n.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var c=this.clone();c._baseState.implicit=null,s=this._createEncoderBuffer(e.map((function(r){var i=this._baseState;return this._getUse(i.args[0],e)._encode(r,t)}),c))}else null!==n.use?a=this._getUse(n.use,r)._encode(e,t):(s=this._encodePrimitive(n.tag,e),o=!0);if(!n.any&&null===n.choice){var d=null!==n.implicit?n.implicit:n.tag,u=null===n.implicit?"universal":"context";null===d?null===n.use&&t.error("Tag could be omitted only for .use()"):null===n.use&&(a=this._encodeComposite(d,o,u,s))}return null!==n.explicit&&(a=this._encodeComposite(n.explicit,!1,"context",a)),a},d.prototype._encodeChoice=function(e,t){var r=this._baseState,i=r.choice[e.type];return i||s(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),i._encode(e.value,t)},d.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},d.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},d.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":44,"minimalistic-assert":239}],46:[function(e,t,r){var i=e("inherits");function n(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function a(e,t){this.path=e,this.rethrow(t)}r.Reporter=n,n.prototype.isError=function(e){return e instanceof a},n.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},n.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},n.prototype.enterKey=function(e){return this._reporterState.path.push(e)},n.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},n.prototype.leaveKey=function(e,t,r){var i=this._reporterState;this.exitKey(e),null!==i.obj&&(i.obj[t]=r)},n.prototype.path=function(){return this._reporterState.path.join("/")},n.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},n.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},n.prototype.error=function(e){var t,r=this._reporterState,i=e instanceof a;if(t=i?e:new a(r.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!r.options.partial)throw t;return i||r.errors.push(t),t},n.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},i(a,Error),a.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,a),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:174}],47:[function(e,t,r){var i=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=i._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=i._reverse(r.tag)},{"../constants":48}],48:[function(e,t,r){var i=r;i._reverse=function(e){var t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);var i=e[r];t[i]=r})),t},i.der=e("./der")},{"./der":47}],49:[function(e,t,r){var i=e("inherits"),n=e("../../asn1"),a=n.base,s=n.bignum,o=n.constants.der;function c(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new d,this.tree._init(e.body)}function d(e){a.Node.call(this,"der",e)}function u(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var i=o.tagClass[r>>6],n=!(32&r);if(31&~r)r&=31;else{var a=r;for(r=0;!(128&~a);){if(a=e.readUInt8(t),e.isError(a))return a;r<<=7,r|=127&a}}return{cls:i,primitive:n,tag:r,tagStr:o.tag[r]}}function l(e,t,r){var i=e.readUInt8(r);if(e.isError(i))return i;if(!t&&128===i)return null;if(!(128&i))return i;var n=127&i;if(n>4)return e.error("length octect is too long");i=0;for(var a=0;a<n;a++){i<<=8;var s=e.readUInt8(r);if(e.isError(s))return s;i|=s}return i}t.exports=c,c.prototype.decode=function(e,t){return e instanceof a.DecoderBuffer||(e=new a.DecoderBuffer(e,t)),this.tree._decode(e,t)},i(d,a.Node),d.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;var i=e.save(),n=u(e,'Failed to peek tag: "'+t+'"');return e.isError(n)?n:(e.restore(i),n.tag===t||n.tagStr===t||n.tagStr+"of"===t||r)},d.prototype._decodeTag=function(e,t,r){var i=u(e,'Failed to decode tag of "'+t+'"');if(e.isError(i))return i;var n=l(e,i.primitive,'Failed to get length of "'+t+'"');if(e.isError(n))return n;if(!r&&i.tag!==t&&i.tagStr!==t&&i.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(i.primitive||null!==n)return e.skip(n,'Failed to match body of: "'+t+'"');var a=e.save(),s=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(s)?s:(n=e.offset-a.offset,e.restore(a),e.skip(n,'Failed to match body of: "'+t+'"'))},d.prototype._skipUntilEnd=function(e,t){for(;;){var r=u(e,t);if(e.isError(r))return r;var i,n=l(e,r.primitive,t);if(e.isError(n))return n;if(i=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(i))return i;if("end"===r.tagStr)break}},d.prototype._decodeList=function(e,t,r,i){for(var n=[];!e.isEmpty();){var a=this._peekTag(e,"end");if(e.isError(a))return a;var s=r.decode(e,"der",i);if(e.isError(s)&&a)break;n.push(s)}return n},d.prototype._decodeStr=function(e,t){if("bitstr"===t){var r=e.readUInt8();return e.isError(r)?r:{unused:r,data:e.raw()}}if("bmpstr"===t){var i=e.raw();if(i.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");for(var n="",a=0;a<i.length/2;a++)n+=String.fromCharCode(i.readUInt16BE(2*a));return n}if("numstr"===t){var s=e.raw().toString("ascii");return this._isNumstr(s)?s:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){var o=e.raw().toString("ascii");return this._isPrintstr(o)?o:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},d.prototype._decodeObjid=function(e,t,r){for(var i,n=[],a=0;!e.isEmpty();){var s=e.readUInt8();a<<=7,a|=127&s,128&s||(n.push(a),a=0)}128&s&&n.push(a);var o=n[0]/40|0,c=n[0]%40;if(i=r?n:[o,c].concat(n.slice(1)),t){var d=t[i.join(" ")];void 0===d&&(d=t[i.join(".")]),void 0!==d&&(i=d)}return i},d.prototype._decodeTime=function(e,t){var r=e.raw().toString();if("gentime"===t)var i=0|r.slice(0,4),n=0|r.slice(4,6),a=0|r.slice(6,8),s=0|r.slice(8,10),o=0|r.slice(10,12),c=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");i=0|r.slice(0,2),n=0|r.slice(2,4),a=0|r.slice(4,6),s=0|r.slice(6,8),o=0|r.slice(8,10),c=0|r.slice(10,12);i=i<70?2e3+i:1900+i}return Date.UTC(i,n-1,a,s,o,c,0)},d.prototype._decodeNull=function(e){return null},d.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},d.prototype._decodeInt=function(e,t){var r=e.raw(),i=new s(r);return t&&(i=t[i.toString(10)]||i),i},d.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree}},{"../../asn1":41,inherits:174}],50:[function(e,t,r){var i=r;i.der=e("./der"),i.pem=e("./pem")},{"./der":49,"./pem":51}],51:[function(e,t,r){var i=e("inherits"),n=e("buffer").Buffer,a=e("./der");function s(e){a.call(this,e),this.enc="pem"}i(s,a),t.exports=s,s.prototype.decode=function(e,t){for(var r=e.toString().split(/[\r\n]+/g),i=t.label.toUpperCase(),s=/^-----(BEGIN|END) ([^-]+)-----$/,o=-1,c=-1,d=0;d<r.length;d++){var u=r[d].match(s);if(null!==u&&u[2]===i){if(-1!==o){if("END"!==u[1])break;c=d;break}if("BEGIN"!==u[1])break;o=d}}if(-1===o||-1===c)throw new Error("PEM section not found for: "+i);var l=r.slice(o+1,c).join("");l.replace(/[^a-z0-9\+\/=]+/gi,"");var h=new n(l,"base64");return a.prototype.decode.call(this,h,t)}},{"./der":49,buffer:94,inherits:174}],52:[function(e,t,r){var i=e("inherits"),n=e("buffer").Buffer,a=e("../../asn1"),s=a.base,o=a.constants.der;function c(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new d,this.tree._init(e.body)}function d(e){s.Node.call(this,"der",e)}function u(e){return e<10?"0"+e:e}t.exports=c,c.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},i(d,s.Node),d.prototype._encodeComposite=function(e,t,r,i){var a,s=function(e,t,r,i){var n;"seqof"===e?e="seq":"setof"===e&&(e="set");if(o.tagByName.hasOwnProperty(e))n=o.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return i.error("Unknown tag: "+e);n=e}if(n>=31)return i.error("Multi-octet tag encoding unsupported");t||(n|=32);return n|=o.tagClassByName[r||"universal"]<<6,n}(e,t,r,this.reporter);if(i.length<128)return(a=new n(2))[0]=s,a[1]=i.length,this._createEncoderBuffer([a,i]);for(var c=1,d=i.length;d>=256;d>>=8)c++;(a=new n(2+c))[0]=s,a[1]=128|c;d=1+c;for(var u=i.length;u>0;d--,u>>=8)a[d]=255&u;return this._createEncoderBuffer([a,i])},d.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new n(2*e.length),i=0;i<e.length;i++)r.writeUInt16BE(e.charCodeAt(i),2*i);return this._createEncoderBuffer(r)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)||"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported")},d.prototype._encodeObjid=function(e,t,r){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!t.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=t[e].split(/[\s\.]+/g);for(var i=0;i<e.length;i++)e[i]|=0}else if(Array.isArray(e)){e=e.slice();for(i=0;i<e.length;i++)e[i]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!r){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var a=0;for(i=0;i<e.length;i++){var s=e[i];for(a++;s>=128;s>>=7)a++}var o=new n(a),c=o.length-1;for(i=e.length-1;i>=0;i--){s=e[i];for(o[c--]=127&s;(s>>=7)>0;)o[c--]=128|127&s}return this._createEncoderBuffer(o)},d.prototype._encodeTime=function(e,t){var r,i=new Date(e);return"gentime"===t?r=[u(i.getFullYear()),u(i.getUTCMonth()+1),u(i.getUTCDate()),u(i.getUTCHours()),u(i.getUTCMinutes()),u(i.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[u(i.getFullYear()%100),u(i.getUTCMonth()+1),u(i.getUTCDate()),u(i.getUTCHours()),u(i.getUTCMinutes()),u(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},d.prototype._encodeNull=function(){return this._createEncoderBuffer("")},d.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!n.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new n(r)}if(n.isBuffer(e)){var i=e.length;0===e.length&&i++;var a=new n(i);return e.copy(a),0===e.length&&(a[0]=0),this._createEncoderBuffer(a)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);i=1;for(var s=e;s>=256;s>>=8)i++;for(s=(a=new Array(i)).length-1;s>=0;s--)a[s]=255&e,e>>=8;return 128&a[0]&&a.unshift(0),this._createEncoderBuffer(new n(a))},d.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},d.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},d.prototype._skipDefault=function(e,t,r){var i,n=this._baseState;if(null===n.default)return!1;var a=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),a.length!==n.defaultBuffer.length)return!1;for(i=0;i<a.length;i++)if(a[i]!==n.defaultBuffer[i])return!1;return!0}},{"../../asn1":41,buffer:94,inherits:174}],53:[function(e,t,r){var i=r;i.der=e("./der"),i.pem=e("./pem")},{"./der":52,"./pem":54}],54:[function(e,t,r){var i=e("inherits"),n=e("./der");function a(e){n.call(this,e),this.enc="pem"}i(a,n),t.exports=a,a.prototype.encode=function(e,t){for(var r=n.prototype.encode.call(this,e).toString("base64"),i=["-----BEGIN "+t.label+"-----"],a=0;a<r.length;a+=64)i.push(r.slice(a,a+64));return i.push("-----END "+t.label+"-----"),i.join("\n")}},{"./der":52,inherits:174}],55:[function(e,t,r){!function(t,r){"use strict";function i(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function a(e,t,r){if(a.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var s;"object"==typeof t?t.exports=a:r.BN=a,a.BN=a,a.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:e("buffer").Buffer}catch(e){}function o(e,t){var r=e.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function c(e,t,r){var i=o(e,r);return r-1>=t&&(i|=o(e,r-1)<<4),i}function d(e,t,r,i){for(var n=0,a=Math.min(e.length,r),s=t;s<a;s++){var o=e.charCodeAt(s)-48;n*=i,n+=o>=49?o-49+10:o>=17?o-17+10:o}return n}a.isBN=function(e){return e instanceof a||null!==e&&"object"==typeof e&&e.constructor.wordSize===a.wordSize&&Array.isArray(e.words)},a.max=function(e,t){return e.cmp(t)>0?e:t},a.min=function(e,t){return e.cmp(t)<0?e:t},a.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),i(t===(0|t)&&t>=2&&t<=36);var n=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<e.length&&(16===t?this._parseHex(e,n,r):(this._parseBase(e,t,n),"le"===r&&this._initArray(this.toArray(),t,r)))},a.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(i(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},a.prototype._initArray=function(e,t,r){if(i("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var a,s,o=0;if("be"===r)for(n=e.length-1,a=0;n>=0;n-=3)s=e[n]|e[n-1]<<8|e[n-2]<<16,this.words[a]|=s<<o&67108863,this.words[a+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,a++);else if("le"===r)for(n=0,a=0;n<e.length;n+=3)s=e[n]|e[n+1]<<8|e[n+2]<<16,this.words[a]|=s<<o&67108863,this.words[a+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,a++);return this.strip()},a.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,a=0,s=0;if("be"===r)for(i=e.length-1;i>=t;i-=2)n=c(e,t,i)<<a,this.words[s]|=67108863&n,a>=18?(a-=18,s+=1,this.words[s]|=n>>>26):a+=8;else for(i=(e.length-t)%2==0?t+1:t;i<e.length;i+=2)n=c(e,t,i)<<a,this.words[s]|=67108863&n,a>=18?(a-=18,s+=1,this.words[s]|=n>>>26):a+=8;this.strip()},a.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=t)i++;i--,n=n/t|0;for(var a=e.length-r,s=a%i,o=Math.min(a,a-s)+r,c=0,u=r;u<o;u+=i)c=d(e,u,u+i,t),this.imuln(n),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var l=1;for(c=d(e,u,e.length,t),u=0;u<s;u++)l*=t;this.imuln(l),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},a.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},a.prototype.clone=function(){var e=new a(null);return this.copy(e),e},a.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},a.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},a.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(e,t,r){r.negative=t.negative^e.negative;var i=e.length+t.length|0;r.length=i,i=i-1|0;var n=0|e.words[0],a=0|t.words[0],s=n*a,o=67108863&s,c=s/67108864|0;r.words[0]=o;for(var d=1;d<i;d++){for(var u=c>>>26,l=67108863&c,h=Math.min(d,t.length-1),f=Math.max(0,d-e.length+1);f<=h;f++){var p=d-f|0;u+=(s=(n=0|e.words[p])*(a=0|t.words[f])+l)/67108864|0,l=67108863&s}r.words[d]=0|l,c=0|u}return 0!==c?r.words[d]=0|c:r.length--,r.strip()}a.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var n=0,a=0,s=0;s<this.length;s++){var o=this.words[s],c=(16777215&(o<<n|a)).toString(16);r=0!==(a=o>>>24-n&16777215)||s!==this.length-1?u[6-c.length]+c+r:c+r,(n+=2)>=26&&(n-=26,s--)}for(0!==a&&(r=a.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var d=l[e],f=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(f).toString(e);r=(p=p.idivn(f)).isZero()?m+r:u[d-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(e,t){return i(void 0!==s),this.toArrayLike(s,e,t)},a.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},a.prototype.toArrayLike=function(e,t,r){var n=this.byteLength(),a=r||Math.max(1,n);i(n<=a,"byte array longer than desired length"),i(a>0,"Requested array length <= 0"),this.strip();var s,o,c="le"===t,d=new e(a),u=this.clone();if(c){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),d[o]=s;for(;o<a;o++)d[o]=0}else{for(o=0;o<a-n;o++)d[o]=0;for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),d[a-o-1]=s}return d},Math.clz32?a.prototype._countBits=function(e){return 32-Math.clz32(e)}:a.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},a.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 8191&t||(r+=13,t>>>=13),127&t||(r+=7,t>>>=7),15&t||(r+=4,t>>>=4),3&t||(r+=2,t>>>=2),1&t||r++,r},a.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);if(e+=r,26!==r)break}return e},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},a.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return 0!==this.negative},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},a.prototype.ior=function(e){return i(!(this.negative|e.negative)),this.iuor(e)},a.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},a.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},a.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]&e.words[r];return this.length=t.length,this.strip()},a.prototype.iand=function(e){return i(!(this.negative|e.negative)),this.iuand(e)},a.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},a.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},a.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var i=0;i<r.length;i++)this.words[i]=t.words[i]^r.words[i];if(this!==t)for(;i<t.length;i++)this.words[i]=t.words[i];return this.length=t.length,this.strip()},a.prototype.ixor=function(e){return i(!(this.negative|e.negative)),this.iuxor(e)},a.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},a.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},a.prototype.inotn=function(e){i("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var n=0;n<t;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},a.prototype.notn=function(e){return this.clone().inotn(e)},a.prototype.setn=function(e,t){i("number"==typeof e&&e>=0);var r=e/26|0,n=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<<n:this.words[r]&~(1<<n),this.strip()},a.prototype.iadd=function(e){var t,r,i;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(r=this,i=e):(r=e,i=this);for(var n=0,a=0;a<i.length;a++)t=(0|r.words[a])+(0|i.words[a])+n,this.words[a]=67108863&t,n=t>>>26;for(;0!==n&&a<r.length;a++)t=(0|r.words[a])+n,this.words[a]=67108863&t,n=t>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this},a.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},a.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,i,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=e):(r=e,i=this);for(var a=0,s=0;s<i.length;s++)a=(t=(0|r.words[s])-(0|i.words[s])+a)>>26,this.words[s]=67108863&t;for(;0!==a&&s<r.length;s++)a=(t=(0|r.words[s])+a)>>26,this.words[s]=67108863&t;if(0===a&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},a.prototype.sub=function(e){return this.clone().isub(e)};var p=function(e,t,r){var i,n,a,s=e.words,o=t.words,c=r.words,d=0,u=0|s[0],l=8191&u,h=u>>>13,f=0|s[1],p=8191&f,m=f>>>13,b=0|s[2],g=8191&b,v=b>>>13,y=0|s[3],_=8191&y,w=y>>>13,S=0|s[4],k=8191&S,R=S>>>13,P=0|s[5],M=8191&P,E=P>>>13,x=0|s[6],T=8191&x,C=x>>>13,I=0|s[7],D=8191&I,O=I>>>13,A=0|s[8],L=8191&A,j=A>>>13,B=0|s[9],N=8191&B,F=B>>>13,U=0|o[0],q=8191&U,z=U>>>13,V=0|o[1],G=8191&V,W=V>>>13,H=0|o[2],K=8191&H,$=H>>>13,J=0|o[3],Y=8191&J,X=J>>>13,Z=0|o[4],Q=8191&Z,ee=Z>>>13,te=0|o[5],re=8191&te,ie=te>>>13,ne=0|o[6],ae=8191&ne,se=ne>>>13,oe=0|o[7],ce=8191&oe,de=oe>>>13,ue=0|o[8],le=8191&ue,he=ue>>>13,fe=0|o[9],pe=8191&fe,me=fe>>>13;r.negative=e.negative^t.negative,r.length=19;var be=(d+(i=Math.imul(l,q))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(h,q)|0))<<13)|0;d=((a=Math.imul(h,z))+(n>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(p,q),n=(n=Math.imul(p,z))+Math.imul(m,q)|0,a=Math.imul(m,z);var ge=(d+(i=i+Math.imul(l,G)|0)|0)+((8191&(n=(n=n+Math.imul(l,W)|0)+Math.imul(h,G)|0))<<13)|0;d=((a=a+Math.imul(h,W)|0)+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(g,q),n=(n=Math.imul(g,z))+Math.imul(v,q)|0,a=Math.imul(v,z),i=i+Math.imul(p,G)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,G)|0,a=a+Math.imul(m,W)|0;var ve=(d+(i=i+Math.imul(l,K)|0)|0)+((8191&(n=(n=n+Math.imul(l,$)|0)+Math.imul(h,K)|0))<<13)|0;d=((a=a+Math.imul(h,$)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(_,q),n=(n=Math.imul(_,z))+Math.imul(w,q)|0,a=Math.imul(w,z),i=i+Math.imul(g,G)|0,n=(n=n+Math.imul(g,W)|0)+Math.imul(v,G)|0,a=a+Math.imul(v,W)|0,i=i+Math.imul(p,K)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(m,K)|0,a=a+Math.imul(m,$)|0;var ye=(d+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(h,Y)|0))<<13)|0;d=((a=a+Math.imul(h,X)|0)+(n>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(k,q),n=(n=Math.imul(k,z))+Math.imul(R,q)|0,a=Math.imul(R,z),i=i+Math.imul(_,G)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(w,G)|0,a=a+Math.imul(w,W)|0,i=i+Math.imul(g,K)|0,n=(n=n+Math.imul(g,$)|0)+Math.imul(v,K)|0,a=a+Math.imul(v,$)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,a=a+Math.imul(m,X)|0;var _e=(d+(i=i+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,ee)|0)+Math.imul(h,Q)|0))<<13)|0;d=((a=a+Math.imul(h,ee)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(M,q),n=(n=Math.imul(M,z))+Math.imul(E,q)|0,a=Math.imul(E,z),i=i+Math.imul(k,G)|0,n=(n=n+Math.imul(k,W)|0)+Math.imul(R,G)|0,a=a+Math.imul(R,W)|0,i=i+Math.imul(_,K)|0,n=(n=n+Math.imul(_,$)|0)+Math.imul(w,K)|0,a=a+Math.imul(w,$)|0,i=i+Math.imul(g,Y)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(v,Y)|0,a=a+Math.imul(v,X)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(m,Q)|0,a=a+Math.imul(m,ee)|0;var we=(d+(i=i+Math.imul(l,re)|0)|0)+((8191&(n=(n=n+Math.imul(l,ie)|0)+Math.imul(h,re)|0))<<13)|0;d=((a=a+Math.imul(h,ie)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(T,q),n=(n=Math.imul(T,z))+Math.imul(C,q)|0,a=Math.imul(C,z),i=i+Math.imul(M,G)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(E,G)|0,a=a+Math.imul(E,W)|0,i=i+Math.imul(k,K)|0,n=(n=n+Math.imul(k,$)|0)+Math.imul(R,K)|0,a=a+Math.imul(R,$)|0,i=i+Math.imul(_,Y)|0,n=(n=n+Math.imul(_,X)|0)+Math.imul(w,Y)|0,a=a+Math.imul(w,X)|0,i=i+Math.imul(g,Q)|0,n=(n=n+Math.imul(g,ee)|0)+Math.imul(v,Q)|0,a=a+Math.imul(v,ee)|0,i=i+Math.imul(p,re)|0,n=(n=n+Math.imul(p,ie)|0)+Math.imul(m,re)|0,a=a+Math.imul(m,ie)|0;var Se=(d+(i=i+Math.imul(l,ae)|0)|0)+((8191&(n=(n=n+Math.imul(l,se)|0)+Math.imul(h,ae)|0))<<13)|0;d=((a=a+Math.imul(h,se)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(D,q),n=(n=Math.imul(D,z))+Math.imul(O,q)|0,a=Math.imul(O,z),i=i+Math.imul(T,G)|0,n=(n=n+Math.imul(T,W)|0)+Math.imul(C,G)|0,a=a+Math.imul(C,W)|0,i=i+Math.imul(M,K)|0,n=(n=n+Math.imul(M,$)|0)+Math.imul(E,K)|0,a=a+Math.imul(E,$)|0,i=i+Math.imul(k,Y)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(R,Y)|0,a=a+Math.imul(R,X)|0,i=i+Math.imul(_,Q)|0,n=(n=n+Math.imul(_,ee)|0)+Math.imul(w,Q)|0,a=a+Math.imul(w,ee)|0,i=i+Math.imul(g,re)|0,n=(n=n+Math.imul(g,ie)|0)+Math.imul(v,re)|0,a=a+Math.imul(v,ie)|0,i=i+Math.imul(p,ae)|0,n=(n=n+Math.imul(p,se)|0)+Math.imul(m,ae)|0,a=a+Math.imul(m,se)|0;var ke=(d+(i=i+Math.imul(l,ce)|0)|0)+((8191&(n=(n=n+Math.imul(l,de)|0)+Math.imul(h,ce)|0))<<13)|0;d=((a=a+Math.imul(h,de)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(L,q),n=(n=Math.imul(L,z))+Math.imul(j,q)|0,a=Math.imul(j,z),i=i+Math.imul(D,G)|0,n=(n=n+Math.imul(D,W)|0)+Math.imul(O,G)|0,a=a+Math.imul(O,W)|0,i=i+Math.imul(T,K)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(C,K)|0,a=a+Math.imul(C,$)|0,i=i+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(E,Y)|0,a=a+Math.imul(E,X)|0,i=i+Math.imul(k,Q)|0,n=(n=n+Math.imul(k,ee)|0)+Math.imul(R,Q)|0,a=a+Math.imul(R,ee)|0,i=i+Math.imul(_,re)|0,n=(n=n+Math.imul(_,ie)|0)+Math.imul(w,re)|0,a=a+Math.imul(w,ie)|0,i=i+Math.imul(g,ae)|0,n=(n=n+Math.imul(g,se)|0)+Math.imul(v,ae)|0,a=a+Math.imul(v,se)|0,i=i+Math.imul(p,ce)|0,n=(n=n+Math.imul(p,de)|0)+Math.imul(m,ce)|0,a=a+Math.imul(m,de)|0;var Re=(d+(i=i+Math.imul(l,le)|0)|0)+((8191&(n=(n=n+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;d=((a=a+Math.imul(h,he)|0)+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863,i=Math.imul(N,q),n=(n=Math.imul(N,z))+Math.imul(F,q)|0,a=Math.imul(F,z),i=i+Math.imul(L,G)|0,n=(n=n+Math.imul(L,W)|0)+Math.imul(j,G)|0,a=a+Math.imul(j,W)|0,i=i+Math.imul(D,K)|0,n=(n=n+Math.imul(D,$)|0)+Math.imul(O,K)|0,a=a+Math.imul(O,$)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(C,Y)|0,a=a+Math.imul(C,X)|0,i=i+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,ee)|0)+Math.imul(E,Q)|0,a=a+Math.imul(E,ee)|0,i=i+Math.imul(k,re)|0,n=(n=n+Math.imul(k,ie)|0)+Math.imul(R,re)|0,a=a+Math.imul(R,ie)|0,i=i+Math.imul(_,ae)|0,n=(n=n+Math.imul(_,se)|0)+Math.imul(w,ae)|0,a=a+Math.imul(w,se)|0,i=i+Math.imul(g,ce)|0,n=(n=n+Math.imul(g,de)|0)+Math.imul(v,ce)|0,a=a+Math.imul(v,de)|0,i=i+Math.imul(p,le)|0,n=(n=n+Math.imul(p,he)|0)+Math.imul(m,le)|0,a=a+Math.imul(m,he)|0;var Pe=(d+(i=i+Math.imul(l,pe)|0)|0)+((8191&(n=(n=n+Math.imul(l,me)|0)+Math.imul(h,pe)|0))<<13)|0;d=((a=a+Math.imul(h,me)|0)+(n>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,i=Math.imul(N,G),n=(n=Math.imul(N,W))+Math.imul(F,G)|0,a=Math.imul(F,W),i=i+Math.imul(L,K)|0,n=(n=n+Math.imul(L,$)|0)+Math.imul(j,K)|0,a=a+Math.imul(j,$)|0,i=i+Math.imul(D,Y)|0,n=(n=n+Math.imul(D,X)|0)+Math.imul(O,Y)|0,a=a+Math.imul(O,X)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,ee)|0)+Math.imul(C,Q)|0,a=a+Math.imul(C,ee)|0,i=i+Math.imul(M,re)|0,n=(n=n+Math.imul(M,ie)|0)+Math.imul(E,re)|0,a=a+Math.imul(E,ie)|0,i=i+Math.imul(k,ae)|0,n=(n=n+Math.imul(k,se)|0)+Math.imul(R,ae)|0,a=a+Math.imul(R,se)|0,i=i+Math.imul(_,ce)|0,n=(n=n+Math.imul(_,de)|0)+Math.imul(w,ce)|0,a=a+Math.imul(w,de)|0,i=i+Math.imul(g,le)|0,n=(n=n+Math.imul(g,he)|0)+Math.imul(v,le)|0,a=a+Math.imul(v,he)|0;var Me=(d+(i=i+Math.imul(p,pe)|0)|0)+((8191&(n=(n=n+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;d=((a=a+Math.imul(m,me)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(N,K),n=(n=Math.imul(N,$))+Math.imul(F,K)|0,a=Math.imul(F,$),i=i+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,a=a+Math.imul(j,X)|0,i=i+Math.imul(D,Q)|0,n=(n=n+Math.imul(D,ee)|0)+Math.imul(O,Q)|0,a=a+Math.imul(O,ee)|0,i=i+Math.imul(T,re)|0,n=(n=n+Math.imul(T,ie)|0)+Math.imul(C,re)|0,a=a+Math.imul(C,ie)|0,i=i+Math.imul(M,ae)|0,n=(n=n+Math.imul(M,se)|0)+Math.imul(E,ae)|0,a=a+Math.imul(E,se)|0,i=i+Math.imul(k,ce)|0,n=(n=n+Math.imul(k,de)|0)+Math.imul(R,ce)|0,a=a+Math.imul(R,de)|0,i=i+Math.imul(_,le)|0,n=(n=n+Math.imul(_,he)|0)+Math.imul(w,le)|0,a=a+Math.imul(w,he)|0;var Ee=(d+(i=i+Math.imul(g,pe)|0)|0)+((8191&(n=(n=n+Math.imul(g,me)|0)+Math.imul(v,pe)|0))<<13)|0;d=((a=a+Math.imul(v,me)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(F,Y)|0,a=Math.imul(F,X),i=i+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,ee)|0)+Math.imul(j,Q)|0,a=a+Math.imul(j,ee)|0,i=i+Math.imul(D,re)|0,n=(n=n+Math.imul(D,ie)|0)+Math.imul(O,re)|0,a=a+Math.imul(O,ie)|0,i=i+Math.imul(T,ae)|0,n=(n=n+Math.imul(T,se)|0)+Math.imul(C,ae)|0,a=a+Math.imul(C,se)|0,i=i+Math.imul(M,ce)|0,n=(n=n+Math.imul(M,de)|0)+Math.imul(E,ce)|0,a=a+Math.imul(E,de)|0,i=i+Math.imul(k,le)|0,n=(n=n+Math.imul(k,he)|0)+Math.imul(R,le)|0,a=a+Math.imul(R,he)|0;var xe=(d+(i=i+Math.imul(_,pe)|0)|0)+((8191&(n=(n=n+Math.imul(_,me)|0)+Math.imul(w,pe)|0))<<13)|0;d=((a=a+Math.imul(w,me)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(N,Q),n=(n=Math.imul(N,ee))+Math.imul(F,Q)|0,a=Math.imul(F,ee),i=i+Math.imul(L,re)|0,n=(n=n+Math.imul(L,ie)|0)+Math.imul(j,re)|0,a=a+Math.imul(j,ie)|0,i=i+Math.imul(D,ae)|0,n=(n=n+Math.imul(D,se)|0)+Math.imul(O,ae)|0,a=a+Math.imul(O,se)|0,i=i+Math.imul(T,ce)|0,n=(n=n+Math.imul(T,de)|0)+Math.imul(C,ce)|0,a=a+Math.imul(C,de)|0,i=i+Math.imul(M,le)|0,n=(n=n+Math.imul(M,he)|0)+Math.imul(E,le)|0,a=a+Math.imul(E,he)|0;var Te=(d+(i=i+Math.imul(k,pe)|0)|0)+((8191&(n=(n=n+Math.imul(k,me)|0)+Math.imul(R,pe)|0))<<13)|0;d=((a=a+Math.imul(R,me)|0)+(n>>>13)|0)+(Te>>>26)|0,Te&=67108863,i=Math.imul(N,re),n=(n=Math.imul(N,ie))+Math.imul(F,re)|0,a=Math.imul(F,ie),i=i+Math.imul(L,ae)|0,n=(n=n+Math.imul(L,se)|0)+Math.imul(j,ae)|0,a=a+Math.imul(j,se)|0,i=i+Math.imul(D,ce)|0,n=(n=n+Math.imul(D,de)|0)+Math.imul(O,ce)|0,a=a+Math.imul(O,de)|0,i=i+Math.imul(T,le)|0,n=(n=n+Math.imul(T,he)|0)+Math.imul(C,le)|0,a=a+Math.imul(C,he)|0;var Ce=(d+(i=i+Math.imul(M,pe)|0)|0)+((8191&(n=(n=n+Math.imul(M,me)|0)+Math.imul(E,pe)|0))<<13)|0;d=((a=a+Math.imul(E,me)|0)+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,i=Math.imul(N,ae),n=(n=Math.imul(N,se))+Math.imul(F,ae)|0,a=Math.imul(F,se),i=i+Math.imul(L,ce)|0,n=(n=n+Math.imul(L,de)|0)+Math.imul(j,ce)|0,a=a+Math.imul(j,de)|0,i=i+Math.imul(D,le)|0,n=(n=n+Math.imul(D,he)|0)+Math.imul(O,le)|0,a=a+Math.imul(O,he)|0;var Ie=(d+(i=i+Math.imul(T,pe)|0)|0)+((8191&(n=(n=n+Math.imul(T,me)|0)+Math.imul(C,pe)|0))<<13)|0;d=((a=a+Math.imul(C,me)|0)+(n>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,i=Math.imul(N,ce),n=(n=Math.imul(N,de))+Math.imul(F,ce)|0,a=Math.imul(F,de),i=i+Math.imul(L,le)|0,n=(n=n+Math.imul(L,he)|0)+Math.imul(j,le)|0,a=a+Math.imul(j,he)|0;var De=(d+(i=i+Math.imul(D,pe)|0)|0)+((8191&(n=(n=n+Math.imul(D,me)|0)+Math.imul(O,pe)|0))<<13)|0;d=((a=a+Math.imul(O,me)|0)+(n>>>13)|0)+(De>>>26)|0,De&=67108863,i=Math.imul(N,le),n=(n=Math.imul(N,he))+Math.imul(F,le)|0,a=Math.imul(F,he);var Oe=(d+(i=i+Math.imul(L,pe)|0)|0)+((8191&(n=(n=n+Math.imul(L,me)|0)+Math.imul(j,pe)|0))<<13)|0;d=((a=a+Math.imul(j,me)|0)+(n>>>13)|0)+(Oe>>>26)|0,Oe&=67108863;var Ae=(d+(i=Math.imul(N,pe))|0)+((8191&(n=(n=Math.imul(N,me))+Math.imul(F,pe)|0))<<13)|0;return d=((a=Math.imul(F,me))+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,c[0]=be,c[1]=ge,c[2]=ve,c[3]=ye,c[4]=_e,c[5]=we,c[6]=Se,c[7]=ke,c[8]=Re,c[9]=Pe,c[10]=Me,c[11]=Ee,c[12]=xe,c[13]=Te,c[14]=Ce,c[15]=Ie,c[16]=De,c[17]=Oe,c[18]=Ae,0!==d&&(c[19]=d,r.length++),r};function m(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(p=f),a.prototype.mulTo=function(e,t){var r,i=this.length+e.length;return r=10===this.length&&10===e.length?p(this,e,t):i<63?f(this,e,t):i<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var i=0,n=0,a=0;a<r.length-1;a++){var s=n;n=0;for(var o=67108863&i,c=Math.min(a,t.length-1),d=Math.max(0,a-e.length+1);d<=c;d++){var u=a-d,l=(0|e.words[u])*(0|t.words[d]),h=67108863&l;o=67108863&(h=h+o|0),n+=(s=(s=s+(l/67108864|0)|0)+(h>>>26)|0)>>>26,s&=67108863}r.words[a]=o,i=s,s=n}return 0!==i?r.words[a]=i:r.length--,r.strip()}(this,e,t):m(this,e,t),r},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=a.prototype._countBits(e)-1,i=0;i<e;i++)t[i]=this.revBin(i,r,e);return t},b.prototype.revBin=function(e,t,r){if(0===e||e===r-1)return e;for(var i=0,n=0;n<t;n++)i|=(1&e)<<t-n-1,e>>=1;return i},b.prototype.permute=function(e,t,r,i,n,a){for(var s=0;s<a;s++)i[s]=t[e[s]],n[s]=r[e[s]]},b.prototype.transform=function(e,t,r,i,n,a){this.permute(a,e,t,r,i,n);for(var s=1;s<n;s<<=1)for(var o=s<<1,c=Math.cos(2*Math.PI/o),d=Math.sin(2*Math.PI/o),u=0;u<n;u+=o)for(var l=c,h=d,f=0;f<s;f++){var p=r[u+f],m=i[u+f],b=r[u+f+s],g=i[u+f+s],v=l*b-h*g;g=l*g+h*b,b=v,r[u+f]=p+b,i[u+f]=m+g,r[u+f+s]=p-b,i[u+f+s]=m-g,f!==o&&(v=c*l-d*h,h=c*h+d*l,l=v)}},b.prototype.guessLen13b=function(e,t){var r=1|Math.max(t,e),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},b.prototype.conjugate=function(e,t,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=e[i];e[i]=e[r-i-1],e[r-i-1]=n,n=t[i],t[i]=-t[r-i-1],t[r-i-1]=-n}},b.prototype.normalize13b=function(e,t){for(var r=0,i=0;i<t/2;i++){var n=8192*Math.round(e[2*i+1]/t)+Math.round(e[2*i]/t)+r;e[i]=67108863&n,r=n<67108864?0:n/67108864|0}return e},b.prototype.convert13b=function(e,t,r,n){for(var a=0,s=0;s<t;s++)a+=0|e[s],r[2*s]=8191&a,a>>>=13,r[2*s+1]=8191&a,a>>>=13;for(s=2*t;s<n;++s)r[s]=0;i(0===a),i(!(-8192&a))},b.prototype.stub=function(e){for(var t=new Array(e),r=0;r<e;r++)t[r]=0;return t},b.prototype.mulp=function(e,t,r){var i=2*this.guessLen13b(e.length,t.length),n=this.makeRBT(i),a=this.stub(i),s=new Array(i),o=new Array(i),c=new Array(i),d=new Array(i),u=new Array(i),l=new Array(i),h=r.words;h.length=i,this.convert13b(e.words,e.length,s,i),this.convert13b(t.words,t.length,d,i),this.transform(s,a,o,c,i,n),this.transform(d,a,u,l,i,n);for(var f=0;f<i;f++){var p=o[f]*u[f]-c[f]*l[f];c[f]=o[f]*l[f]+c[f]*u[f],o[f]=p}return this.conjugate(o,c,i),this.transform(o,c,h,a,i,n),this.conjugate(h,a,i),this.normalize13b(h,i),r.negative=e.negative^t.negative,r.length=e.length+t.length,r.strip()},a.prototype.mul=function(e){var t=new a(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},a.prototype.mulf=function(e){var t=new a(null);return t.words=new Array(this.length+e.length),m(this,e,t)},a.prototype.imul=function(e){return this.clone().mulTo(e,this)},a.prototype.imuln=function(e){i("number"==typeof e),i(e<67108864);for(var t=0,r=0;r<this.length;r++){var n=(0|this.words[r])*e,a=(67108863&n)+(67108863&t);t>>=26,t+=n/67108864|0,t+=a>>>26,this.words[r]=67108863&a}return 0!==t&&(this.words[r]=t,this.length++),this},a.prototype.muln=function(e){return this.clone().imuln(e)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r<t.length;r++){var i=r/26|0,n=r%26;t[r]=(e.words[i]&1<<n)>>>n}return t}(e);if(0===t.length)return new a(1);for(var r=this,i=0;i<t.length&&0===t[i];i++,r=r.sqr());if(++i<t.length)for(var n=r.sqr();i<t.length;i++,n=n.sqr())0!==t[i]&&(r=r.mul(n));return r},a.prototype.iushln=function(e){i("number"==typeof e&&e>=0);var t,r=e%26,n=(e-r)/26,a=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t<this.length;t++){var o=this.words[t]&a,c=(0|this.words[t])-o<<r;this.words[t]=c|s,s=o>>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==n){for(t=this.length-1;t>=0;t--)this.words[t+n]=this.words[t];for(t=0;t<n;t++)this.words[t]=0;this.length+=n}return this.strip()},a.prototype.ishln=function(e){return i(0===this.negative),this.iushln(e)},a.prototype.iushrn=function(e,t,r){var n;i("number"==typeof e&&e>=0),n=t?(t-t%26)/26:0;var a=e%26,s=Math.min((e-a)/26,this.length),o=67108863^67108863>>>a<<a,c=r;if(n-=s,n=Math.max(0,n),c){for(var d=0;d<s;d++)c.words[d]=this.words[d];c.length=s}if(0===s);else if(this.length>s)for(this.length-=s,d=0;d<this.length;d++)this.words[d]=this.words[d+s];else this.words[0]=0,this.length=1;var u=0;for(d=this.length-1;d>=0&&(0!==u||d>=n);d--){var l=0|this.words[d];this.words[d]=u<<26-a|l>>>a,u=l&o}return c&&0!==u&&(c.words[c.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(e,t,r){return i(0===this.negative),this.iushrn(e,t,r)},a.prototype.shln=function(e){return this.clone().ishln(e)},a.prototype.ushln=function(e){return this.clone().iushln(e)},a.prototype.shrn=function(e){return this.clone().ishrn(e)},a.prototype.ushrn=function(e){return this.clone().iushrn(e)},a.prototype.testn=function(e){i("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,n=1<<t;return!(this.length<=r)&&!!(this.words[r]&n)},a.prototype.imaskn=function(e){i("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var n=67108863^67108863>>>t<<t;this.words[this.length-1]&=n}return this.strip()},a.prototype.maskn=function(e){return this.clone().imaskn(e)},a.prototype.iaddn=function(e){return i("number"==typeof e),i(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},a.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},a.prototype.isubn=function(e){if(i("number"==typeof e),i(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},a.prototype.addn=function(e){return this.clone().iaddn(e)},a.prototype.subn=function(e){return this.clone().isubn(e)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(e,t,r){var n,a,s=e.length+r;this._expand(s);var o=0;for(n=0;n<e.length;n++){a=(0|this.words[n+r])+o;var c=(0|e.words[n])*t;o=((a-=67108863&c)>>26)-(c/67108864|0),this.words[n+r]=67108863&a}for(;n<this.length-r;n++)o=(a=(0|this.words[n+r])+o)>>26,this.words[n+r]=67108863&a;if(0===o)return this.strip();for(i(-1===o),o=0,n=0;n<this.length;n++)o=(a=-(0|this.words[n])+o)>>26,this.words[n]=67108863&a;return this.negative=1,this.strip()},a.prototype._wordDiv=function(e,t){var r=(this.length,e.length),i=this.clone(),n=e,s=0|n.words[n.length-1];0!==(r=26-this._countBits(s))&&(n=n.ushln(r),i.iushln(r),s=0|n.words[n.length-1]);var o,c=i.length-n.length;if("mod"!==t){(o=new a(null)).length=c+1,o.words=new Array(o.length);for(var d=0;d<o.length;d++)o.words[d]=0}var u=i.clone()._ishlnsubmul(n,1,c);0===u.negative&&(i=u,o&&(o.words[c]=1));for(var l=c-1;l>=0;l--){var h=67108864*(0|i.words[n.length+l])+(0|i.words[n.length+l-1]);for(h=Math.min(h/s|0,67108863),i._ishlnsubmul(n,h,l);0!==i.negative;)h--,i.negative=0,i._ishlnsubmul(n,1,l),i.isZero()||(i.negative^=1);o&&(o.words[l]=h)}return o&&o.strip(),i.strip(),"div"!==t&&0!==r&&i.iushrn(r),{div:o||null,mod:i}},a.prototype.divmod=function(e,t,r){return i(!e.isZero()),this.isZero()?{div:new a(0),mod:new a(0)}:0!==this.negative&&0===e.negative?(o=this.neg().divmod(e,t),"mod"!==t&&(n=o.div.neg()),"div"!==t&&(s=o.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:n,mod:s}):0===this.negative&&0!==e.negative?(o=this.divmod(e.neg(),t),"mod"!==t&&(n=o.div.neg()),{div:n,mod:o.mod}):this.negative&e.negative?(o=this.neg().divmod(e.neg(),t),"div"!==t&&(s=o.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:o.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new a(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new a(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new a(this.modn(e.words[0]))}:this._wordDiv(e,t);var n,s,o},a.prototype.div=function(e){return this.divmod(e,"div",!1).div},a.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},a.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},a.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),n=e.andln(1),a=r.cmp(i);return a<0||1===n&&0===a?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},a.prototype.modn=function(e){i(e<=67108863);for(var t=(1<<26)%e,r=0,n=this.length-1;n>=0;n--)r=(t*r+(0|this.words[n]))%e;return r},a.prototype.idivn=function(e){i(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*t;this.words[r]=n/e|0,t=n%e}return this.strip()},a.prototype.divn=function(e){return this.clone().idivn(e)},a.prototype.egcd=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n=new a(1),s=new a(0),o=new a(0),c=new a(1),d=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++d;for(var u=r.clone(),l=t.clone();!t.isZero();){for(var h=0,f=1;!(t.words[0]&f)&&h<26;++h,f<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(l)),n.iushrn(1),s.iushrn(1);for(var p=0,m=1;!(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(o.isOdd()||c.isOdd())&&(o.iadd(u),c.isub(l)),o.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),n.isub(o),s.isub(c)):(r.isub(t),o.isub(n),c.isub(s))}return{a:o,b:c,gcd:r.iushln(d)}},a.prototype._invmp=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n,s=new a(1),o=new a(0),c=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var d=0,u=1;!(t.words[0]&u)&&d<26;++d,u<<=1);if(d>0)for(t.iushrn(d);d-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var l=0,h=1;!(r.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(r.iushrn(l);l-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(o)):(r.isub(t),o.isub(s))}return(n=0===t.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(e),n},a.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var i=0;t.isEven()&&r.isEven();i++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=t.cmp(r);if(n<0){var a=t;t=r,r=a}else if(0===n||0===r.cmpn(1))break;t.isub(r)}return r.iushln(i)},a.prototype.invm=function(e){return this.egcd(e).a.umod(e)},a.prototype.isEven=function(){return!(1&this.words[0])},a.prototype.isOdd=function(){return!(1&~this.words[0])},a.prototype.andln=function(e){return this.words[0]&e},a.prototype.bincn=function(e){i("number"==typeof e);var t=e%26,r=(e-t)/26,n=1<<t;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var a=n,s=r;0!==a&&s<this.length;s++){var o=0|this.words[s];a=(o+=a)>>>26,o&=67108863,this.words[s]=o}return 0!==a&&(this.words[s]=a,this.length++),this},a.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},a.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),i(e<=67108863,"Number is too big");var n=0|this.words[0];t=n===e?0:n<e?-1:1}return 0!==this.negative?0|-t:t},a.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},a.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|e.words[r];if(i!==n){i<n?t=-1:i>n&&(t=1);break}}return t},a.prototype.gtn=function(e){return 1===this.cmpn(e)},a.prototype.gt=function(e){return 1===this.cmp(e)},a.prototype.gten=function(e){return this.cmpn(e)>=0},a.prototype.gte=function(e){return this.cmp(e)>=0},a.prototype.ltn=function(e){return-1===this.cmpn(e)},a.prototype.lt=function(e){return-1===this.cmp(e)},a.prototype.lten=function(e){return this.cmpn(e)<=0},a.prototype.lte=function(e){return this.cmp(e)<=0},a.prototype.eqn=function(e){return 0===this.cmpn(e)},a.prototype.eq=function(e){return 0===this.cmp(e)},a.red=function(e){return new k(e)},a.prototype.toRed=function(e){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(e){return this.red=e,this},a.prototype.forceRed=function(e){return i(!this.red,"Already a number in reduction context"),this._forceRed(e)},a.prototype.redAdd=function(e){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},a.prototype.redIAdd=function(e){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},a.prototype.redSub=function(e){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},a.prototype.redISub=function(e){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},a.prototype.redShl=function(e){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},a.prototype.redMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},a.prototype.redIMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},a.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(e){return i(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new a(t,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function k(e){if("string"==typeof e){var t=a._prime(e);this.m=t.p,this.prime=t}else i(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function R(e){k.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var e=new a(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var i=t<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},n(y,v),y.prototype.split=function(e,t){for(var r=4194303,i=Math.min(e.length,9),n=0;n<i;n++)t.words[n]=e.words[n];if(t.length=i,e.length<=9)return e.words[0]=0,void(e.length=1);var a=e.words[9];for(t.words[t.length++]=a&r,n=10;n<e.length;n++){var s=0|e.words[n];e.words[n-10]=(s&r)<<4|a>>>22,a=s}a>>>=22,e.words[n-10]=a,0===a&&e.length>10?e.length-=10:e.length-=9},y.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r<e.length;r++){var i=0|e.words[r];t+=977*i,e.words[r]=67108863&t,t=64*i+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},n(_,v),n(w,v),n(S,v),S.prototype.imulK=function(e){for(var t=0,r=0;r<e.length;r++){var i=19*(0|e.words[r])+t,n=67108863&i;i>>>=26,e.words[r]=n,t=i}return 0!==t&&(e.words[e.length++]=t),e},a._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new y;else if("p224"===e)t=new _;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new S}return g[e]=t,t},k.prototype._verify1=function(e){i(0===e.negative,"red works only with positives"),i(e.red,"red works only with red numbers")},k.prototype._verify2=function(e,t){i(!(e.negative|t.negative),"red works only with positives"),i(e.red&&e.red===t.red,"red works only with red numbers")},k.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},k.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},k.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},k.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},k.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},k.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},k.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},k.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},k.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},k.prototype.isqr=function(e){return this.imul(e,e.clone())},k.prototype.sqr=function(e){return this.mul(e,e)},k.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(i(t%2==1),3===t){var r=this.m.add(new a(1)).iushrn(2);return this.pow(e,r)}for(var n=this.m.subn(1),s=0;!n.isZero()&&0===n.andln(1);)s++,n.iushrn(1);i(!n.isZero());var o=new a(1).toRed(this),c=o.redNeg(),d=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new a(2*u*u).toRed(this);0!==this.pow(u,d).cmp(c);)u.redIAdd(c);for(var l=this.pow(u,n),h=this.pow(e,n.addn(1).iushrn(1)),f=this.pow(e,n),p=s;0!==f.cmp(o);){for(var m=f,b=0;0!==m.cmp(o);b++)m=m.redSqr();i(b<p);var g=this.pow(l,new a(1).iushln(p-b-1));h=h.redMul(g),l=g.redSqr(),f=f.redMul(l),p=b}return h},k.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},k.prototype.pow=function(e,t){if(t.isZero())return new a(1).toRed(this);if(0===t.cmpn(1))return e.clone();var r=new Array(16);r[0]=new a(1).toRed(this),r[1]=e;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],e);var n=r[0],s=0,o=0,c=t.bitLength()%26;for(0===c&&(c=26),i=t.length-1;i>=0;i--){for(var d=t.words[i],u=c-1;u>=0;u--){var l=d>>u&1;n!==r[0]&&(n=this.sqr(n)),0!==l||0!==s?(s<<=1,s|=l,(4===++o||0===i&&0===u)&&(n=this.mul(n,r[s]),o=0,s=0)):o=0}c=26}return n},k.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},k.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},a.mont=function(e){return new R(e)},n(R,k),R.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},R.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},R.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),a=n;return n.cmp(this.m)>=0?a=n.isub(this.m):n.cmpn(0)<0&&(a=n.iadd(this.m)),a._forceRed(this)},R.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new a(0)._forceRed(this);var r=e.mul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},R.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:63}],56:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Logger=void 0;const i=e("debug"),n="awaitqueue";r.Logger=class{constructor(e){e?(this._debug=(0,i.default)(`${n}:${e}`),this._warn=(0,i.default)(`${n}:WARN:${e}`),this._error=(0,i.default)(`${n}:ERROR:${e}`)):(this._debug=(0,i.default)(n),this._warn=(0,i.default)(`${n}:WARN`),this._error=(0,i.default)(`${n}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}}},{debug:104}],57:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.AwaitQueue=r.AwaitQueueRemovedTaskError=r.AwaitQueueStoppedError=void 0;const i=new(e("./Logger").Logger);class n extends Error{constructor(e){super(e??"AwaitQueue stopped"),this.name="AwaitQueueStoppedError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,n)}}r.AwaitQueueStoppedError=n;class a extends Error{constructor(e){super(e??"AwaitQueue task removed"),this.name="AwaitQueueRemovedTaskError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,a)}}r.AwaitQueueRemovedTaskError=a;r.AwaitQueue=class{constructor(){this.pendingTasks=new Map,this.nextTaskId=0,this.stopping=!1}get size(){return this.pendingTasks.size}async push(e,t){if(t=t??e.name,i.debug(`push() [name:${t}]`),"function"!=typeof e)throw new TypeError("given task is not a function");if(t)try{Object.defineProperty(e,"name",{value:t})}catch(e){}return new Promise(((r,n)=>{const a={id:this.nextTaskId++,task:e,name:t,enqueuedAt:Date.now(),executedAt:void 0,completed:!1,resolve:e=>{if(a.completed)return;a.completed=!0,this.pendingTasks.delete(a.id),i.debug(`resolving task [name:${a.name}]`),r(e);const[t]=this.pendingTasks.values();t&&!t.executedAt&&this.execute(t)},reject:e=>{if(!a.completed&&(a.completed=!0,this.pendingTasks.delete(a.id),i.debug(`rejecting task [name:${a.name}]: %s`,String(e)),n(e),!this.stopping)){const[e]=this.pendingTasks.values();e&&!e.executedAt&&this.execute(e)}}};this.pendingTasks.set(a.id,a),1===this.pendingTasks.size&&this.execute(a)}))}stop(){i.debug("stop()"),this.stopping=!0;for(const e of this.pendingTasks.values())i.debug(`stop() | stopping task [name:${e.name}]`),e.reject(new n);this.stopping=!1}remove(e){i.debug(`remove() [taskIdx:${e}]`);const t=Array.from(this.pendingTasks.values())[e];t?t.reject(new a):i.debug(`stop() | no task with given idx [taskIdx:${e}]`)}dump(){const e=Date.now();let t=0;return Array.from(this.pendingTasks.values()).map((r=>({idx:t++,task:r.task,name:r.name,enqueuedTime:r.executedAt?r.executedAt-r.enqueuedAt:e-r.enqueuedAt,executionTime:r.executedAt?e-r.executedAt:0})))}async execute(e){if(i.debug(`execute() [name:${e.name}]`),e.executedAt)throw new Error("task already being executed");e.executedAt=Date.now();try{const t=await e.task();e.resolve(t)}catch(t){e.reject(t)}}}},{"./Logger":56}],58:[function(e,t,r){(function(e,r){(function(){"use strict";function i(e,t){return function(){return e.apply(t,arguments)}}const{toString:n}=Object.prototype,{getPrototypeOf:a}=Object,s=(o=Object.create(null),e=>{const t=n.call(e);return o[t]||(o[t]=t.slice(8,-1).toLowerCase())});var o;const c=e=>(e=e.toLowerCase(),t=>s(t)===e),d=e=>t=>typeof t===e,{isArray:u}=Array,l=d("undefined");const h=c("ArrayBuffer");const f=d("string"),p=d("function"),m=d("number"),b=e=>null!==e&&"object"==typeof e,g=e=>{if("object"!==s(e))return!1;const t=a(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},v=c("Date"),y=c("File"),_=c("Blob"),w=c("FileList"),S=c("URLSearchParams");function k(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let i,n;if("object"!=typeof e&&(e=[e]),u(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{const n=r?Object.getOwnPropertyNames(e):Object.keys(e),a=n.length;let s;for(i=0;i<a;i++)s=n[i],t.call(null,e[s],s,e)}}function R(e,t){t=t.toLowerCase();const r=Object.keys(e);let i,n=r.length;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}const P="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:e,M=e=>!l(e)&&e!==P;const E=(x="undefined"!=typeof Uint8Array&&a(Uint8Array),e=>x&&e instanceof x);var x;const T=c("HTMLFormElement"),C=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),I=c("RegExp"),D=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),i={};k(r,((r,n)=>{let a;!1!==(a=t(r,n,e))&&(i[n]=a||r)})),Object.defineProperties(e,i)},O="abcdefghijklmnopqrstuvwxyz",A="0123456789",L={DIGIT:A,ALPHA:O,ALPHA_DIGIT:O+O.toUpperCase()+A};const j=c("AsyncFunction");var B={isArray:u,isArrayBuffer:h,isBuffer:function(e){return null!==e&&!l(e)&&null!==e.constructor&&!l(e.constructor)&&p(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||p(e.append)&&("formdata"===(t=s(e))||"object"===t&&p(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&h(e.buffer),t},isString:f,isNumber:m,isBoolean:e=>!0===e||!1===e,isObject:b,isPlainObject:g,isUndefined:l,isDate:v,isFile:y,isBlob:_,isRegExp:I,isFunction:p,isStream:e=>b(e)&&p(e.pipe),isURLSearchParams:S,isTypedArray:E,isFileList:w,forEach:k,merge:function e(){const{caseless:t}=M(this)&&this||{},r={},i=(i,n)=>{const a=t&&R(r,n)||n;g(r[a])&&g(i)?r[a]=e(r[a],i):g(i)?r[a]=e({},i):u(i)?r[a]=i.slice():r[a]=i};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&k(arguments[e],i);return r},extend:(e,t,r,{allOwnKeys:n}={})=>(k(t,((t,n)=>{r&&p(t)?e[n]=i(t,r):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,i)=>{let n,s,o;const c={};if(t=t||{},null==e)return t;do{for(n=Object.getOwnPropertyNames(e),s=n.length;s-- >0;)o=n[s],i&&!i(o,e,t)||c[o]||(t[o]=e[o],c[o]=!0);e=!1!==r&&a(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:s,kindOfTest:c,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const i=e.indexOf(t,r);return-1!==i&&i===r},toArray:e=>{if(!e)return null;if(u(e))return e;let t=e.length;if(!m(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let i;for(;(i=r.next())&&!i.done;){const r=i.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const i=[];for(;null!==(r=e.exec(t));)i.push(r);return i},isHTMLForm:T,hasOwnProperty:C,hasOwnProp:C,reduceDescriptors:D,freezeMethods:e=>{D(e,((t,r)=>{if(p(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const i=e[r];p(i)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},i=e=>{e.forEach((e=>{r[e]=!0}))};return u(e)?i(e):i(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:R,global:P,isContextDefined:M,ALPHABET:L,generateString:(e=16,t=L.ALPHA_DIGIT)=>{let r="";const{length:i}=t;for(;e--;)r+=t[Math.random()*i|0];return r},isSpecCompliantForm:function(e){return!!(e&&p(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),r=(e,i)=>{if(b(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[i]=e;const n=u(e)?[]:{};return k(e,((e,t)=>{const a=r(e,i+1);!l(a)&&(n[t]=a)})),t[i]=void 0,n}}return e};return r(e,0)},isAsyncFn:j,isThenable:e=>e&&(b(e)||p(e))&&p(e.then)&&p(e.catch)};function N(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n)}B.inherits(N,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:B.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const F=N.prototype,U={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{U[e]={value:e}})),Object.defineProperties(N,U),Object.defineProperty(F,"isAxiosError",{value:!0}),N.from=(e,t,r,i,n,a)=>{const s=Object.create(F);return B.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),N.call(s,e.message,t,r,i,n),s.cause=e,s.name=e.name,a&&Object.assign(s,a),s};function q(e){return B.isPlainObject(e)||B.isArray(e)}function z(e){return B.endsWith(e,"[]")?e.slice(0,-2):e}function V(e,t,r){return e?e.concat(t).map((function(e,t){return e=z(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const G=B.toFlatObject(B,{},null,(function(e){return/^is[A-Z]/.test(e)}));function W(e,t,i){if(!B.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(i=B.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!B.isUndefined(t[e])}))).metaTokens,a=i.visitor||u,s=i.dots,o=i.indexes,c=(i.Blob||"undefined"!=typeof Blob&&Blob)&&B.isSpecCompliantForm(t);if(!B.isFunction(a))throw new TypeError("visitor must be a function");function d(e){if(null===e)return"";if(B.isDate(e))return e.toISOString();if(!c&&B.isBlob(e))throw new N("Blob is not supported. Use a Buffer instead.");return B.isArrayBuffer(e)||B.isTypedArray(e)?c&&"function"==typeof Blob?new Blob([e]):r.from(e):e}function u(e,r,i){let a=e;if(e&&!i&&"object"==typeof e)if(B.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(B.isArray(e)&&function(e){return B.isArray(e)&&!e.some(q)}(e)||(B.isFileList(e)||B.endsWith(r,"[]"))&&(a=B.toArray(e)))return r=z(r),a.forEach((function(e,i){!B.isUndefined(e)&&null!==e&&t.append(!0===o?V([r],i,s):null===o?r:r+"[]",d(e))})),!1;return!!q(e)||(t.append(V(i,r,s),d(e)),!1)}const l=[],h=Object.assign(G,{defaultVisitor:u,convertValue:d,isVisitable:q});if(!B.isObject(e))throw new TypeError("data must be an object");return function e(r,i){if(!B.isUndefined(r)){if(-1!==l.indexOf(r))throw Error("Circular reference detected in "+i.join("."));l.push(r),B.forEach(r,(function(r,n){!0===(!(B.isUndefined(r)||null===r)&&a.call(t,r,B.isString(n)?n.trim():n,i,h))&&e(r,i?i.concat(n):[n])})),l.pop()}}(e),t}function H(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function K(e,t){this._pairs=[],e&&W(e,this,t)}const $=K.prototype;function J(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Y(e,t,r){if(!t)return e;const i=r&&r.encode||J,n=r&&r.serialize;let a;if(a=n?n(t,r):B.isURLSearchParams(t)?t.toString():new K(t,r).toString(i),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}$.append=function(e,t){this._pairs.push([e,t])},$.toString=function(e){const t=e?function(t){return e.call(this,t,H)}:H;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var X=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){B.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},Z={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Q={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:K,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:(()=>{let e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&("undefined"!=typeof window&&"undefined"!=typeof document)})(),isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]};function ee(e){function t(e,r,i,n){let a=e[n++];const s=Number.isFinite(+a),o=n>=e.length;if(a=!a&&B.isArray(i)?i.length:a,o)return B.hasOwnProp(i,a)?i[a]=[i[a],r]:i[a]=r,!s;i[a]&&B.isObject(i[a])||(i[a]=[]);return t(e,r,i[a],n)&&B.isArray(i[a])&&(i[a]=function(e){const t={},r=Object.keys(e);let i;const n=r.length;let a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}(i[a])),!s}if(B.isFormData(e)&&B.isFunction(e.entries)){const r={};return B.forEachEntry(e,((e,i)=>{t(function(e){return B.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),i,r,0)})),r}return null}const te={transitional:Z,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",i=r.indexOf("application/json")>-1,n=B.isObject(e);n&&B.isHTMLForm(e)&&(e=new FormData(e));if(B.isFormData(e))return i&&i?JSON.stringify(ee(e)):e;if(B.isArrayBuffer(e)||B.isBuffer(e)||B.isStream(e)||B.isFile(e)||B.isBlob(e))return e;if(B.isArrayBufferView(e))return e.buffer;if(B.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(n){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return W(e,new Q.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,i){return Q.isNode&&B.isBuffer(e)?(this.append(t,e.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((a=B.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return W(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return n||i?(t.setContentType("application/json",!1),function(e,t,r){if(B.isString(e))try{return(t||JSON.parse)(e),B.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||te.transitional,r=t&&t.forcedJSONParsing,i="json"===this.responseType;if(e&&B.isString(e)&&(r&&!this.responseType||i)){const r=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw N.from(e,N.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Q.classes.FormData,Blob:Q.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};B.forEach(["delete","get","head","post","put","patch"],(e=>{te.headers[e]={}}));var re=te;const ie=B.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const ne=Symbol("internals");function ae(e){return e&&String(e).trim().toLowerCase()}function se(e){return!1===e||null==e?e:B.isArray(e)?e.map(se):String(e)}function oe(e,t,r,i,n){return B.isFunction(i)?i.call(this,t,r):(n&&(t=r),B.isString(t)?B.isString(i)?-1!==t.indexOf(i):B.isRegExp(i)?i.test(t):void 0:void 0)}class ce{constructor(e){e&&this.set(e)}set(e,t,r){const i=this;function n(e,t,r){const n=ae(t);if(!n)throw new Error("header name must be a non-empty string");const a=B.findKey(i,n);(!a||void 0===i[a]||!0===r||void 0===r&&!1!==i[a])&&(i[a||t]=se(e))}const a=(e,t)=>B.forEach(e,((e,r)=>n(e,r,t)));return B.isPlainObject(e)||e instanceof this.constructor?a(e,t):B.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?a((e=>{const t={};let r,i,n;return e&&e.split("\n").forEach((function(e){n=e.indexOf(":"),r=e.substring(0,n).trim().toLowerCase(),i=e.substring(n+1).trim(),!r||t[r]&&ie[r]||("set-cookie"===r?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)})),t})(e),t):null!=e&&n(t,e,r),this}get(e,t){if(e=ae(e)){const r=B.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=r.exec(e);)t[i[1]]=i[2];return t}(e);if(B.isFunction(t))return t.call(this,e,r);if(B.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ae(e)){const r=B.findKey(this,e);return!(!r||void 0===this[r]||t&&!oe(0,this[r],r,t))}return!1}delete(e,t){const r=this;let i=!1;function n(e){if(e=ae(e)){const n=B.findKey(r,e);!n||t&&!oe(0,r[n],n,t)||(delete r[n],i=!0)}}return B.isArray(e)?e.forEach(n):n(e),i}clear(e){const t=Object.keys(this);let r=t.length,i=!1;for(;r--;){const n=t[r];e&&!oe(0,this[n],n,e,!0)||(delete this[n],i=!0)}return i}normalize(e){const t=this,r={};return B.forEach(this,((i,n)=>{const a=B.findKey(r,n);if(a)return t[a]=se(i),void delete t[n];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(n):String(n).trim();s!==n&&delete t[n],t[s]=se(i),r[s]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return B.forEach(this,((r,i)=>{null!=r&&!1!==r&&(t[i]=e&&B.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[ne]=this[ne]={accessors:{}}).accessors,r=this.prototype;function i(e){const i=ae(e);t[i]||(!function(e,t){const r=B.toCamelCase(" "+t);["get","set","has"].forEach((i=>{Object.defineProperty(e,i+r,{value:function(e,r,n){return this[i].call(this,t,e,r,n)},configurable:!0})}))}(r,e),t[i]=!0)}return B.isArray(e)?e.forEach(i):i(e),this}}ce.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),B.reduceDescriptors(ce.prototype,(({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}})),B.freezeMethods(ce);var de=ce;function ue(e,t){const r=this||re,i=t||r,n=de.from(i.headers);let a=i.data;return B.forEach(e,(function(e){a=e.call(r,a,n.normalize(),t?t.status:void 0)})),n.normalize(),a}function le(e){return!(!e||!e.__CANCEL__)}function he(e,t,r){N.call(this,null==e?"canceled":e,N.ERR_CANCELED,t,r),this.name="CanceledError"}B.inherits(he,N,{__CANCEL__:!0});var fe=Q.isStandardBrowserEnv?{write:function(e,t,r,i,n,a){const s=[];s.push(e+"="+encodeURIComponent(t)),B.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),B.isString(i)&&s.push("path="+i),B.isString(n)&&s.push("domain="+n),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function pe(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var me=Q.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function i(r){let i=r;return e&&(t.setAttribute("href",i),i=t.href),t.setAttribute("href",i),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return r=i(window.location.href),function(e){const t=B.isString(e)?i(e):e;return t.protocol===r.protocol&&t.host===r.host}}():function(){return!0};function be(e,t){let r=0;const i=function(e,t){e=e||10;const r=new Array(e),i=new Array(e);let n,a=0,s=0;return t=void 0!==t?t:1e3,function(o){const c=Date.now(),d=i[s];n||(n=c),r[a]=o,i[a]=c;let u=s,l=0;for(;u!==a;)l+=r[u++],u%=e;if(a=(a+1)%e,a===s&&(s=(s+1)%e),c-n<t)return;const h=d&&c-d;return h?Math.round(1e3*l/h):void 0}}(50,250);return n=>{const a=n.loaded,s=n.lengthComputable?n.total:void 0,o=a-r,c=i(o);r=a;const d={loaded:a,total:s,progress:s?a/s:void 0,bytes:o,rate:c||void 0,estimated:c&&s&&a<=s?(s-a)/c:void 0,event:n};d[t?"download":"upload"]=!0,e(d)}}const ge={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){let i=e.data;const n=de.from(e.headers).normalize(),a=e.responseType;let s,o;function c(){e.cancelToken&&e.cancelToken.unsubscribe(s),e.signal&&e.signal.removeEventListener("abort",s)}B.isFormData(i)&&(Q.isStandardBrowserEnv||Q.isStandardBrowserWebWorkerEnv?n.setContentType(!1):n.getContentType(/^\s*multipart\/form-data/)?B.isString(o=n.getContentType())&&n.setContentType(o.replace(/^\s*(multipart\/form-data);+/,"$1")):n.setContentType("multipart/form-data"));let d=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",r=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";n.set("Authorization","Basic "+btoa(t+":"+r))}const u=pe(e.baseURL,e.url);function l(){if(!d)return;const i=de.from("getAllResponseHeaders"in d&&d.getAllResponseHeaders());!function(e,t,r){const i=r.config.validateStatus;r.status&&i&&!i(r.status)?t(new N("Request failed with status code "+r.status,[N.ERR_BAD_REQUEST,N.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),c()}),(function(e){r(e),c()}),{data:a&&"text"!==a&&"json"!==a?d.response:d.responseText,status:d.status,statusText:d.statusText,headers:i,config:e,request:d}),d=null}if(d.open(e.method.toUpperCase(),Y(u,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,"onloadend"in d?d.onloadend=l:d.onreadystatechange=function(){d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))&&setTimeout(l)},d.onabort=function(){d&&(r(new N("Request aborted",N.ECONNABORTED,e,d)),d=null)},d.onerror=function(){r(new N("Network Error",N.ERR_NETWORK,e,d)),d=null},d.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const i=e.transitional||Z;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new N(t,i.clarifyTimeoutError?N.ETIMEDOUT:N.ECONNABORTED,e,d)),d=null},Q.isStandardBrowserEnv){const t=me(u)&&e.xsrfCookieName&&fe.read(e.xsrfCookieName);t&&n.set(e.xsrfHeaderName,t)}void 0===i&&n.setContentType(null),"setRequestHeader"in d&&B.forEach(n.toJSON(),(function(e,t){d.setRequestHeader(t,e)})),B.isUndefined(e.withCredentials)||(d.withCredentials=!!e.withCredentials),a&&"json"!==a&&(d.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&d.addEventListener("progress",be(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",be(e.onUploadProgress)),(e.cancelToken||e.signal)&&(s=t=>{d&&(r(!t||t.type?new he(null,e,d):t),d.abort(),d=null)},e.cancelToken&&e.cancelToken.subscribe(s),e.signal&&(e.signal.aborted?s():e.signal.addEventListener("abort",s)));const h=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(u);h&&-1===Q.protocols.indexOf(h)?r(new N("Unsupported protocol "+h+":",N.ERR_BAD_REQUEST,e)):d.send(i||null)}))}};B.forEach(ge,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const ve=e=>`- ${e}`,ye=e=>B.isFunction(e)||null===e||!1===e;var _e=e=>{e=B.isArray(e)?e:[e];const{length:t}=e;let r,i;const n={};for(let a=0;a<t;a++){let t;if(r=e[a],i=r,!ye(r)&&(i=ge[(t=String(r)).toLowerCase()],void 0===i))throw new N(`Unknown adapter '${t}'`);if(i)break;n[t||"#"+a]=i}if(!i){const e=Object.entries(n).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new N("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(ve).join("\n"):" "+ve(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i};function we(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new he(null,e)}function Se(e){we(e),e.headers=de.from(e.headers),e.data=ue.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return _e(e.adapter||re.adapter)(e).then((function(t){return we(e),t.data=ue.call(e,e.transformResponse,t),t.headers=de.from(t.headers),t}),(function(t){return le(t)||(we(e),t&&t.response&&(t.response.data=ue.call(e,e.transformResponse,t.response),t.response.headers=de.from(t.response.headers))),Promise.reject(t)}))}const ke=e=>e instanceof de?e.toJSON():e;function Re(e,t){t=t||{};const r={};function i(e,t,r){return B.isPlainObject(e)&&B.isPlainObject(t)?B.merge.call({caseless:r},e,t):B.isPlainObject(t)?B.merge({},t):B.isArray(t)?t.slice():t}function n(e,t,r){return B.isUndefined(t)?B.isUndefined(e)?void 0:i(void 0,e,r):i(e,t,r)}function a(e,t){if(!B.isUndefined(t))return i(void 0,t)}function s(e,t){return B.isUndefined(t)?B.isUndefined(e)?void 0:i(void 0,e):i(void 0,t)}function o(r,n,a){return a in t?i(r,n):a in e?i(void 0,r):void 0}const c={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:o,headers:(e,t)=>n(ke(e),ke(t),!0)};return B.forEach(Object.keys(Object.assign({},e,t)),(function(i){const a=c[i]||n,s=a(e[i],t[i],i);B.isUndefined(s)&&a!==o||(r[i]=s)})),r}const Pe="1.6.0",Me={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{Me[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const Ee={};Me.transitional=function(e,t,r){function i(e,t){return"[Axios v1.6.0] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,n,a)=>{if(!1===e)throw new N(i(n," has been removed"+(t?" in "+t:"")),N.ERR_DEPRECATED);return t&&!Ee[n]&&(Ee[n]=!0,console.warn(i(n," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,n,a)}};var xe={assertOptions:function(e,t,r){if("object"!=typeof e)throw new N("options must be an object",N.ERR_BAD_OPTION_VALUE);const i=Object.keys(e);let n=i.length;for(;n-- >0;){const a=i[n],s=t[a];if(s){const t=e[a],r=void 0===t||s(t,a,e);if(!0!==r)throw new N("option "+a+" must be "+r,N.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new N("Unknown option "+a,N.ERR_BAD_OPTION)}},validators:Me};const Te=xe.validators;class Ce{constructor(e){this.defaults=e,this.interceptors={request:new X,response:new X}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Re(this.defaults,t);const{transitional:r,paramsSerializer:i,headers:n}=t;void 0!==r&&xe.assertOptions(r,{silentJSONParsing:Te.transitional(Te.boolean),forcedJSONParsing:Te.transitional(Te.boolean),clarifyTimeoutError:Te.transitional(Te.boolean)},!1),null!=i&&(B.isFunction(i)?t.paramsSerializer={serialize:i}:xe.assertOptions(i,{encode:Te.function,serialize:Te.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=n&&B.merge(n.common,n[t.method]);n&&B.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete n[e]})),t.headers=de.concat(a,n);const s=[];let o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const c=[];let d;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let u,l=0;if(!o){const e=[Se.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,c),u=e.length,d=Promise.resolve(t);l<u;)d=d.then(e[l++],e[l++]);return d}u=s.length;let h=t;for(l=0;l<u;){const e=s[l++],t=s[l++];try{h=e(h)}catch(e){t.call(this,e);break}}try{d=Se.call(this,h)}catch(e){return Promise.reject(e)}for(l=0,u=c.length;l<u;)d=d.then(c[l++],c[l++]);return d}getUri(e){return Y(pe((e=Re(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}B.forEach(["delete","get","head","options"],(function(e){Ce.prototype[e]=function(t,r){return this.request(Re(r||{},{method:e,url:t,data:(r||{}).data}))}})),B.forEach(["post","put","patch"],(function(e){function t(t){return function(r,i,n){return this.request(Re(n||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:i}))}}Ce.prototype[e]=t(),Ce.prototype[e+"Form"]=t(!0)}));var Ie=Ce;class De{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const i=new Promise((e=>{r.subscribe(e),t=e})).then(e);return i.cancel=function(){r.unsubscribe(t)},i},e((function(e,i,n){r.reason||(r.reason=new he(e,i,n),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;return{token:new De((function(t){e=t})),cancel:e}}}var Oe=De;const Ae={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ae).forEach((([e,t])=>{Ae[t]=e}));var Le=Ae;const je=function e(t){const r=new Ie(t),n=i(Ie.prototype.request,r);return B.extend(n,Ie.prototype,r,{allOwnKeys:!0}),B.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(Re(t,r))},n}(re);je.Axios=Ie,je.CanceledError=he,je.CancelToken=Oe,je.isCancel=le,je.VERSION=Pe,je.toFormData=W,je.AxiosError=N,je.Cancel=je.CanceledError,je.all=function(e){return Promise.all(e)},je.spread=function(e){return function(t){return e.apply(null,t)}},je.isAxiosError=function(e){return B.isObject(e)&&!0===e.isAxiosError},je.mergeConfig=Re,je.AxiosHeaders=de,je.formToJSON=e=>ee(B.isHTMLForm(e)?new FormData(e):e),je.getAdapter=_e,je.HttpStatusCode=Le,je.default=je,t.exports=je}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{buffer:94}],59:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],i=t[1];return 3*(r+i)/4-i},r.toByteArray=function(e){var t,r,i=c(e),s=i[0],o=i[1],d=new a(function(e,t,r){return 3*(t+r)/4-r}(0,s,o)),u=0,l=o>0?s-4:s;for(r=0;r<l;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],d[u++]=t>>16&255,d[u++]=t>>8&255,d[u++]=255&t;2===o&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,d[u++]=255&t);1===o&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,d[u++]=t>>8&255,d[u++]=255&t);return d},r.fromByteArray=function(e){for(var t,r=e.length,n=r%3,a=[],s=16383,o=0,c=r-n;o<c;o+=s)a.push(d(e,o,o+s>c?c:o+s));1===n?(t=e[r-1],a.push(i[t>>2]+i[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],a.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return a.join("")};for(var i=[],n=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)i[o]=s[o],n[s.charCodeAt(o)]=o;function c(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 d(e,t,r){for(var n,a,s=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),s.push(i[(a=n)>>18&63]+i[a>>12&63]+i[a>>6&63]+i[63&a]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},{}],60:[function(e,t,r){!function(t,r){"use strict";function i(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function a(e,t,r){if(a.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var s;"object"==typeof t?t.exports=a:r.BN=a,a.BN=a,a.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:e("buffer").Buffer}catch(e){}function o(e,t){var r=e.charCodeAt(t);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void i(!1,"Invalid character in "+e)}function c(e,t,r){var i=o(e,r);return r-1>=t&&(i|=o(e,r-1)<<4),i}function d(e,t,r,n){for(var a=0,s=0,o=Math.min(e.length,r),c=t;c<o;c++){var d=e.charCodeAt(c)-48;a*=n,s=d>=49?d-49+10:d>=17?d-17+10:d,i(d>=0&&s<n,"Invalid character"),a+=s}return a}function u(e,t){e.words=t.words,e.length=t.length,e.negative=t.negative,e.red=t.red}if(a.isBN=function(e){return e instanceof a||null!==e&&"object"==typeof e&&e.constructor.wordSize===a.wordSize&&Array.isArray(e.words)},a.max=function(e,t){return e.cmp(t)>0?e:t},a.min=function(e,t){return e.cmp(t)<0?e:t},a.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),i(t===(0|t)&&t>=2&&t<=36);var n=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<e.length&&(16===t?this._parseHex(e,n,r):(this._parseBase(e,t,n),"le"===r&&this._initArray(this.toArray(),t,r)))},a.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(i(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},a.prototype._initArray=function(e,t,r){if(i("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var a,s,o=0;if("be"===r)for(n=e.length-1,a=0;n>=0;n-=3)s=e[n]|e[n-1]<<8|e[n-2]<<16,this.words[a]|=s<<o&67108863,this.words[a+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,a++);else if("le"===r)for(n=0,a=0;n<e.length;n+=3)s=e[n]|e[n+1]<<8|e[n+2]<<16,this.words[a]|=s<<o&67108863,this.words[a+1]=s>>>26-o&67108863,(o+=24)>=26&&(o-=26,a++);return this._strip()},a.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,a=0,s=0;if("be"===r)for(i=e.length-1;i>=t;i-=2)n=c(e,t,i)<<a,this.words[s]|=67108863&n,a>=18?(a-=18,s+=1,this.words[s]|=n>>>26):a+=8;else for(i=(e.length-t)%2==0?t+1:t;i<e.length;i+=2)n=c(e,t,i)<<a,this.words[s]|=67108863&n,a>=18?(a-=18,s+=1,this.words[s]|=n>>>26):a+=8;this._strip()},a.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=t)i++;i--,n=n/t|0;for(var a=e.length-r,s=a%i,o=Math.min(a,a-s)+r,c=0,u=r;u<o;u+=i)c=d(e,u,u+i,t),this.imuln(n),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var l=1;for(c=d(e,u,e.length,t),u=0;u<s;u++)l*=t;this.imuln(l),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},a.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},a.prototype._move=function(e){u(e,this)},a.prototype.clone=function(){var e=new a(null);return this.copy(e),e},a.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},a.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},a.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{a.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(e){a.prototype.inspect=l}else a.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var h=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];a.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var n=0,a=0,s=0;s<this.length;s++){var o=this.words[s],c=(16777215&(o<<n|a)).toString(16);a=o>>>24-n&16777215,(n+=2)>=26&&(n-=26,s--),r=0!==a||s!==this.length-1?h[6-c.length]+c+r:c+r}for(0!==a&&(r=a.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var d=f[e],u=p[e];r="";var l=this.clone();for(l.negative=0;!l.isZero();){var m=l.modrn(u).toString(e);r=(l=l.idivn(u)).isZero()?m+r:h[d-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},a.prototype.toJSON=function(){return this.toString(16,2)},s&&(a.prototype.toBuffer=function(e,t){return this.toArrayLike(s,e,t)}),a.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function m(e,t,r){r.negative=t.negative^e.negative;var i=e.length+t.length|0;r.length=i,i=i-1|0;var n=0|e.words[0],a=0|t.words[0],s=n*a,o=67108863&s,c=s/67108864|0;r.words[0]=o;for(var d=1;d<i;d++){for(var u=c>>>26,l=67108863&c,h=Math.min(d,t.length-1),f=Math.max(0,d-e.length+1);f<=h;f++){var p=d-f|0;u+=(s=(n=0|e.words[p])*(a=0|t.words[f])+l)/67108864|0,l=67108863&s}r.words[d]=0|l,c=0|u}return 0!==c?r.words[d]=0|c:r.length--,r._strip()}a.prototype.toArrayLike=function(e,t,r){this._strip();var n=this.byteLength(),a=r||Math.max(1,n);i(n<=a,"byte array longer than desired length"),i(a>0,"Requested array length <= 0");var s=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,a);return this["_toArrayLike"+("le"===t?"LE":"BE")](s,n),s},a.prototype._toArrayLikeLE=function(e,t){for(var r=0,i=0,n=0,a=0;n<this.length;n++){var s=this.words[n]<<a|i;e[r++]=255&s,r<e.length&&(e[r++]=s>>8&255),r<e.length&&(e[r++]=s>>16&255),6===a?(r<e.length&&(e[r++]=s>>24&255),i=0,a=0):(i=s>>>24,a+=2)}if(r<e.length)for(e[r++]=i;r<e.length;)e[r++]=0},a.prototype._toArrayLikeBE=function(e,t){for(var r=e.length-1,i=0,n=0,a=0;n<this.length;n++){var s=this.words[n]<<a|i;e[r--]=255&s,r>=0&&(e[r--]=s>>8&255),r>=0&&(e[r--]=s>>16&255),6===a?(r>=0&&(e[r--]=s>>24&255),i=0,a=0):(i=s>>>24,a+=2)}if(r>=0)for(e[r--]=i;r>=0;)e[r--]=0},Math.clz32?a.prototype._countBits=function(e){return 32-Math.clz32(e)}:a.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},a.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 8191&t||(r+=13,t>>>=13),127&t||(r+=7,t>>>=7),15&t||(r+=4,t>>>=4),3&t||(r+=2,t>>>=2),1&t||r++,r},a.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);if(e+=r,26!==r)break}return e},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},a.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return 0!==this.negative},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this._strip()},a.prototype.ior=function(e){return i(!(this.negative|e.negative)),this.iuor(e)},a.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},a.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},a.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]&e.words[r];return this.length=t.length,this._strip()},a.prototype.iand=function(e){return i(!(this.negative|e.negative)),this.iuand(e)},a.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},a.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},a.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var i=0;i<r.length;i++)this.words[i]=t.words[i]^r.words[i];if(this!==t)for(;i<t.length;i++)this.words[i]=t.words[i];return this.length=t.length,this._strip()},a.prototype.ixor=function(e){return i(!(this.negative|e.negative)),this.iuxor(e)},a.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},a.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},a.prototype.inotn=function(e){i("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var n=0;n<t;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},a.prototype.notn=function(e){return this.clone().inotn(e)},a.prototype.setn=function(e,t){i("number"==typeof e&&e>=0);var r=e/26|0,n=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},a.prototype.iadd=function(e){var t,r,i;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(r=this,i=e):(r=e,i=this);for(var n=0,a=0;a<i.length;a++)t=(0|r.words[a])+(0|i.words[a])+n,this.words[a]=67108863&t,n=t>>>26;for(;0!==n&&a<r.length;a++)t=(0|r.words[a])+n,this.words[a]=67108863&t,n=t>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this},a.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},a.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,i,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=e):(r=e,i=this);for(var a=0,s=0;s<i.length;s++)a=(t=(0|r.words[s])-(0|i.words[s])+a)>>26,this.words[s]=67108863&t;for(;0!==a&&s<r.length;s++)a=(t=(0|r.words[s])+a)>>26,this.words[s]=67108863&t;if(0===a&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(e){return this.clone().isub(e)};var b=function(e,t,r){var i,n,a,s=e.words,o=t.words,c=r.words,d=0,u=0|s[0],l=8191&u,h=u>>>13,f=0|s[1],p=8191&f,m=f>>>13,b=0|s[2],g=8191&b,v=b>>>13,y=0|s[3],_=8191&y,w=y>>>13,S=0|s[4],k=8191&S,R=S>>>13,P=0|s[5],M=8191&P,E=P>>>13,x=0|s[6],T=8191&x,C=x>>>13,I=0|s[7],D=8191&I,O=I>>>13,A=0|s[8],L=8191&A,j=A>>>13,B=0|s[9],N=8191&B,F=B>>>13,U=0|o[0],q=8191&U,z=U>>>13,V=0|o[1],G=8191&V,W=V>>>13,H=0|o[2],K=8191&H,$=H>>>13,J=0|o[3],Y=8191&J,X=J>>>13,Z=0|o[4],Q=8191&Z,ee=Z>>>13,te=0|o[5],re=8191&te,ie=te>>>13,ne=0|o[6],ae=8191&ne,se=ne>>>13,oe=0|o[7],ce=8191&oe,de=oe>>>13,ue=0|o[8],le=8191&ue,he=ue>>>13,fe=0|o[9],pe=8191&fe,me=fe>>>13;r.negative=e.negative^t.negative,r.length=19;var be=(d+(i=Math.imul(l,q))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(h,q)|0))<<13)|0;d=((a=Math.imul(h,z))+(n>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(p,q),n=(n=Math.imul(p,z))+Math.imul(m,q)|0,a=Math.imul(m,z);var ge=(d+(i=i+Math.imul(l,G)|0)|0)+((8191&(n=(n=n+Math.imul(l,W)|0)+Math.imul(h,G)|0))<<13)|0;d=((a=a+Math.imul(h,W)|0)+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(g,q),n=(n=Math.imul(g,z))+Math.imul(v,q)|0,a=Math.imul(v,z),i=i+Math.imul(p,G)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,G)|0,a=a+Math.imul(m,W)|0;var ve=(d+(i=i+Math.imul(l,K)|0)|0)+((8191&(n=(n=n+Math.imul(l,$)|0)+Math.imul(h,K)|0))<<13)|0;d=((a=a+Math.imul(h,$)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(_,q),n=(n=Math.imul(_,z))+Math.imul(w,q)|0,a=Math.imul(w,z),i=i+Math.imul(g,G)|0,n=(n=n+Math.imul(g,W)|0)+Math.imul(v,G)|0,a=a+Math.imul(v,W)|0,i=i+Math.imul(p,K)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(m,K)|0,a=a+Math.imul(m,$)|0;var ye=(d+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(h,Y)|0))<<13)|0;d=((a=a+Math.imul(h,X)|0)+(n>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(k,q),n=(n=Math.imul(k,z))+Math.imul(R,q)|0,a=Math.imul(R,z),i=i+Math.imul(_,G)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(w,G)|0,a=a+Math.imul(w,W)|0,i=i+Math.imul(g,K)|0,n=(n=n+Math.imul(g,$)|0)+Math.imul(v,K)|0,a=a+Math.imul(v,$)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,a=a+Math.imul(m,X)|0;var _e=(d+(i=i+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,ee)|0)+Math.imul(h,Q)|0))<<13)|0;d=((a=a+Math.imul(h,ee)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(M,q),n=(n=Math.imul(M,z))+Math.imul(E,q)|0,a=Math.imul(E,z),i=i+Math.imul(k,G)|0,n=(n=n+Math.imul(k,W)|0)+Math.imul(R,G)|0,a=a+Math.imul(R,W)|0,i=i+Math.imul(_,K)|0,n=(n=n+Math.imul(_,$)|0)+Math.imul(w,K)|0,a=a+Math.imul(w,$)|0,i=i+Math.imul(g,Y)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(v,Y)|0,a=a+Math.imul(v,X)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(m,Q)|0,a=a+Math.imul(m,ee)|0;var we=(d+(i=i+Math.imul(l,re)|0)|0)+((8191&(n=(n=n+Math.imul(l,ie)|0)+Math.imul(h,re)|0))<<13)|0;d=((a=a+Math.imul(h,ie)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(T,q),n=(n=Math.imul(T,z))+Math.imul(C,q)|0,a=Math.imul(C,z),i=i+Math.imul(M,G)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(E,G)|0,a=a+Math.imul(E,W)|0,i=i+Math.imul(k,K)|0,n=(n=n+Math.imul(k,$)|0)+Math.imul(R,K)|0,a=a+Math.imul(R,$)|0,i=i+Math.imul(_,Y)|0,n=(n=n+Math.imul(_,X)|0)+Math.imul(w,Y)|0,a=a+Math.imul(w,X)|0,i=i+Math.imul(g,Q)|0,n=(n=n+Math.imul(g,ee)|0)+Math.imul(v,Q)|0,a=a+Math.imul(v,ee)|0,i=i+Math.imul(p,re)|0,n=(n=n+Math.imul(p,ie)|0)+Math.imul(m,re)|0,a=a+Math.imul(m,ie)|0;var Se=(d+(i=i+Math.imul(l,ae)|0)|0)+((8191&(n=(n=n+Math.imul(l,se)|0)+Math.imul(h,ae)|0))<<13)|0;d=((a=a+Math.imul(h,se)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(D,q),n=(n=Math.imul(D,z))+Math.imul(O,q)|0,a=Math.imul(O,z),i=i+Math.imul(T,G)|0,n=(n=n+Math.imul(T,W)|0)+Math.imul(C,G)|0,a=a+Math.imul(C,W)|0,i=i+Math.imul(M,K)|0,n=(n=n+Math.imul(M,$)|0)+Math.imul(E,K)|0,a=a+Math.imul(E,$)|0,i=i+Math.imul(k,Y)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(R,Y)|0,a=a+Math.imul(R,X)|0,i=i+Math.imul(_,Q)|0,n=(n=n+Math.imul(_,ee)|0)+Math.imul(w,Q)|0,a=a+Math.imul(w,ee)|0,i=i+Math.imul(g,re)|0,n=(n=n+Math.imul(g,ie)|0)+Math.imul(v,re)|0,a=a+Math.imul(v,ie)|0,i=i+Math.imul(p,ae)|0,n=(n=n+Math.imul(p,se)|0)+Math.imul(m,ae)|0,a=a+Math.imul(m,se)|0;var ke=(d+(i=i+Math.imul(l,ce)|0)|0)+((8191&(n=(n=n+Math.imul(l,de)|0)+Math.imul(h,ce)|0))<<13)|0;d=((a=a+Math.imul(h,de)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(L,q),n=(n=Math.imul(L,z))+Math.imul(j,q)|0,a=Math.imul(j,z),i=i+Math.imul(D,G)|0,n=(n=n+Math.imul(D,W)|0)+Math.imul(O,G)|0,a=a+Math.imul(O,W)|0,i=i+Math.imul(T,K)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(C,K)|0,a=a+Math.imul(C,$)|0,i=i+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(E,Y)|0,a=a+Math.imul(E,X)|0,i=i+Math.imul(k,Q)|0,n=(n=n+Math.imul(k,ee)|0)+Math.imul(R,Q)|0,a=a+Math.imul(R,ee)|0,i=i+Math.imul(_,re)|0,n=(n=n+Math.imul(_,ie)|0)+Math.imul(w,re)|0,a=a+Math.imul(w,ie)|0,i=i+Math.imul(g,ae)|0,n=(n=n+Math.imul(g,se)|0)+Math.imul(v,ae)|0,a=a+Math.imul(v,se)|0,i=i+Math.imul(p,ce)|0,n=(n=n+Math.imul(p,de)|0)+Math.imul(m,ce)|0,a=a+Math.imul(m,de)|0;var Re=(d+(i=i+Math.imul(l,le)|0)|0)+((8191&(n=(n=n+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;d=((a=a+Math.imul(h,he)|0)+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863,i=Math.imul(N,q),n=(n=Math.imul(N,z))+Math.imul(F,q)|0,a=Math.imul(F,z),i=i+Math.imul(L,G)|0,n=(n=n+Math.imul(L,W)|0)+Math.imul(j,G)|0,a=a+Math.imul(j,W)|0,i=i+Math.imul(D,K)|0,n=(n=n+Math.imul(D,$)|0)+Math.imul(O,K)|0,a=a+Math.imul(O,$)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(C,Y)|0,a=a+Math.imul(C,X)|0,i=i+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,ee)|0)+Math.imul(E,Q)|0,a=a+Math.imul(E,ee)|0,i=i+Math.imul(k,re)|0,n=(n=n+Math.imul(k,ie)|0)+Math.imul(R,re)|0,a=a+Math.imul(R,ie)|0,i=i+Math.imul(_,ae)|0,n=(n=n+Math.imul(_,se)|0)+Math.imul(w,ae)|0,a=a+Math.imul(w,se)|0,i=i+Math.imul(g,ce)|0,n=(n=n+Math.imul(g,de)|0)+Math.imul(v,ce)|0,a=a+Math.imul(v,de)|0,i=i+Math.imul(p,le)|0,n=(n=n+Math.imul(p,he)|0)+Math.imul(m,le)|0,a=a+Math.imul(m,he)|0;var Pe=(d+(i=i+Math.imul(l,pe)|0)|0)+((8191&(n=(n=n+Math.imul(l,me)|0)+Math.imul(h,pe)|0))<<13)|0;d=((a=a+Math.imul(h,me)|0)+(n>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,i=Math.imul(N,G),n=(n=Math.imul(N,W))+Math.imul(F,G)|0,a=Math.imul(F,W),i=i+Math.imul(L,K)|0,n=(n=n+Math.imul(L,$)|0)+Math.imul(j,K)|0,a=a+Math.imul(j,$)|0,i=i+Math.imul(D,Y)|0,n=(n=n+Math.imul(D,X)|0)+Math.imul(O,Y)|0,a=a+Math.imul(O,X)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,ee)|0)+Math.imul(C,Q)|0,a=a+Math.imul(C,ee)|0,i=i+Math.imul(M,re)|0,n=(n=n+Math.imul(M,ie)|0)+Math.imul(E,re)|0,a=a+Math.imul(E,ie)|0,i=i+Math.imul(k,ae)|0,n=(n=n+Math.imul(k,se)|0)+Math.imul(R,ae)|0,a=a+Math.imul(R,se)|0,i=i+Math.imul(_,ce)|0,n=(n=n+Math.imul(_,de)|0)+Math.imul(w,ce)|0,a=a+Math.imul(w,de)|0,i=i+Math.imul(g,le)|0,n=(n=n+Math.imul(g,he)|0)+Math.imul(v,le)|0,a=a+Math.imul(v,he)|0;var Me=(d+(i=i+Math.imul(p,pe)|0)|0)+((8191&(n=(n=n+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;d=((a=a+Math.imul(m,me)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(N,K),n=(n=Math.imul(N,$))+Math.imul(F,K)|0,a=Math.imul(F,$),i=i+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,a=a+Math.imul(j,X)|0,i=i+Math.imul(D,Q)|0,n=(n=n+Math.imul(D,ee)|0)+Math.imul(O,Q)|0,a=a+Math.imul(O,ee)|0,i=i+Math.imul(T,re)|0,n=(n=n+Math.imul(T,ie)|0)+Math.imul(C,re)|0,a=a+Math.imul(C,ie)|0,i=i+Math.imul(M,ae)|0,n=(n=n+Math.imul(M,se)|0)+Math.imul(E,ae)|0,a=a+Math.imul(E,se)|0,i=i+Math.imul(k,ce)|0,n=(n=n+Math.imul(k,de)|0)+Math.imul(R,ce)|0,a=a+Math.imul(R,de)|0,i=i+Math.imul(_,le)|0,n=(n=n+Math.imul(_,he)|0)+Math.imul(w,le)|0,a=a+Math.imul(w,he)|0;var Ee=(d+(i=i+Math.imul(g,pe)|0)|0)+((8191&(n=(n=n+Math.imul(g,me)|0)+Math.imul(v,pe)|0))<<13)|0;d=((a=a+Math.imul(v,me)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(F,Y)|0,a=Math.imul(F,X),i=i+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,ee)|0)+Math.imul(j,Q)|0,a=a+Math.imul(j,ee)|0,i=i+Math.imul(D,re)|0,n=(n=n+Math.imul(D,ie)|0)+Math.imul(O,re)|0,a=a+Math.imul(O,ie)|0,i=i+Math.imul(T,ae)|0,n=(n=n+Math.imul(T,se)|0)+Math.imul(C,ae)|0,a=a+Math.imul(C,se)|0,i=i+Math.imul(M,ce)|0,n=(n=n+Math.imul(M,de)|0)+Math.imul(E,ce)|0,a=a+Math.imul(E,de)|0,i=i+Math.imul(k,le)|0,n=(n=n+Math.imul(k,he)|0)+Math.imul(R,le)|0,a=a+Math.imul(R,he)|0;var xe=(d+(i=i+Math.imul(_,pe)|0)|0)+((8191&(n=(n=n+Math.imul(_,me)|0)+Math.imul(w,pe)|0))<<13)|0;d=((a=a+Math.imul(w,me)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(N,Q),n=(n=Math.imul(N,ee))+Math.imul(F,Q)|0,a=Math.imul(F,ee),i=i+Math.imul(L,re)|0,n=(n=n+Math.imul(L,ie)|0)+Math.imul(j,re)|0,a=a+Math.imul(j,ie)|0,i=i+Math.imul(D,ae)|0,n=(n=n+Math.imul(D,se)|0)+Math.imul(O,ae)|0,a=a+Math.imul(O,se)|0,i=i+Math.imul(T,ce)|0,n=(n=n+Math.imul(T,de)|0)+Math.imul(C,ce)|0,a=a+Math.imul(C,de)|0,i=i+Math.imul(M,le)|0,n=(n=n+Math.imul(M,he)|0)+Math.imul(E,le)|0,a=a+Math.imul(E,he)|0;var Te=(d+(i=i+Math.imul(k,pe)|0)|0)+((8191&(n=(n=n+Math.imul(k,me)|0)+Math.imul(R,pe)|0))<<13)|0;d=((a=a+Math.imul(R,me)|0)+(n>>>13)|0)+(Te>>>26)|0,Te&=67108863,i=Math.imul(N,re),n=(n=Math.imul(N,ie))+Math.imul(F,re)|0,a=Math.imul(F,ie),i=i+Math.imul(L,ae)|0,n=(n=n+Math.imul(L,se)|0)+Math.imul(j,ae)|0,a=a+Math.imul(j,se)|0,i=i+Math.imul(D,ce)|0,n=(n=n+Math.imul(D,de)|0)+Math.imul(O,ce)|0,a=a+Math.imul(O,de)|0,i=i+Math.imul(T,le)|0,n=(n=n+Math.imul(T,he)|0)+Math.imul(C,le)|0,a=a+Math.imul(C,he)|0;var Ce=(d+(i=i+Math.imul(M,pe)|0)|0)+((8191&(n=(n=n+Math.imul(M,me)|0)+Math.imul(E,pe)|0))<<13)|0;d=((a=a+Math.imul(E,me)|0)+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,i=Math.imul(N,ae),n=(n=Math.imul(N,se))+Math.imul(F,ae)|0,a=Math.imul(F,se),i=i+Math.imul(L,ce)|0,n=(n=n+Math.imul(L,de)|0)+Math.imul(j,ce)|0,a=a+Math.imul(j,de)|0,i=i+Math.imul(D,le)|0,n=(n=n+Math.imul(D,he)|0)+Math.imul(O,le)|0,a=a+Math.imul(O,he)|0;var Ie=(d+(i=i+Math.imul(T,pe)|0)|0)+((8191&(n=(n=n+Math.imul(T,me)|0)+Math.imul(C,pe)|0))<<13)|0;d=((a=a+Math.imul(C,me)|0)+(n>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,i=Math.imul(N,ce),n=(n=Math.imul(N,de))+Math.imul(F,ce)|0,a=Math.imul(F,de),i=i+Math.imul(L,le)|0,n=(n=n+Math.imul(L,he)|0)+Math.imul(j,le)|0,a=a+Math.imul(j,he)|0;var De=(d+(i=i+Math.imul(D,pe)|0)|0)+((8191&(n=(n=n+Math.imul(D,me)|0)+Math.imul(O,pe)|0))<<13)|0;d=((a=a+Math.imul(O,me)|0)+(n>>>13)|0)+(De>>>26)|0,De&=67108863,i=Math.imul(N,le),n=(n=Math.imul(N,he))+Math.imul(F,le)|0,a=Math.imul(F,he);var Oe=(d+(i=i+Math.imul(L,pe)|0)|0)+((8191&(n=(n=n+Math.imul(L,me)|0)+Math.imul(j,pe)|0))<<13)|0;d=((a=a+Math.imul(j,me)|0)+(n>>>13)|0)+(Oe>>>26)|0,Oe&=67108863;var Ae=(d+(i=Math.imul(N,pe))|0)+((8191&(n=(n=Math.imul(N,me))+Math.imul(F,pe)|0))<<13)|0;return d=((a=Math.imul(F,me))+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,c[0]=be,c[1]=ge,c[2]=ve,c[3]=ye,c[4]=_e,c[5]=we,c[6]=Se,c[7]=ke,c[8]=Re,c[9]=Pe,c[10]=Me,c[11]=Ee,c[12]=xe,c[13]=Te,c[14]=Ce,c[15]=Ie,c[16]=De,c[17]=Oe,c[18]=Ae,0!==d&&(c[19]=d,r.length++),r};function g(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var i=0,n=0,a=0;a<r.length-1;a++){var s=n;n=0;for(var o=67108863&i,c=Math.min(a,t.length-1),d=Math.max(0,a-e.length+1);d<=c;d++){var u=a-d,l=(0|e.words[u])*(0|t.words[d]),h=67108863&l;o=67108863&(h=h+o|0),n+=(s=(s=s+(l/67108864|0)|0)+(h>>>26)|0)>>>26,s&=67108863}r.words[a]=o,i=s,s=n}return 0!==i?r.words[a]=i:r.length--,r._strip()}function v(e,t,r){return g(e,t,r)}function y(e,t){this.x=e,this.y=t}Math.imul||(b=m),a.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?b(this,e,t):r<63?m(this,e,t):r<1024?g(this,e,t):v(this,e,t)},y.prototype.makeRBT=function(e){for(var t=new Array(e),r=a.prototype._countBits(e)-1,i=0;i<e;i++)t[i]=this.revBin(i,r,e);return t},y.prototype.revBin=function(e,t,r){if(0===e||e===r-1)return e;for(var i=0,n=0;n<t;n++)i|=(1&e)<<t-n-1,e>>=1;return i},y.prototype.permute=function(e,t,r,i,n,a){for(var s=0;s<a;s++)i[s]=t[e[s]],n[s]=r[e[s]]},y.prototype.transform=function(e,t,r,i,n,a){this.permute(a,e,t,r,i,n);for(var s=1;s<n;s<<=1)for(var o=s<<1,c=Math.cos(2*Math.PI/o),d=Math.sin(2*Math.PI/o),u=0;u<n;u+=o)for(var l=c,h=d,f=0;f<s;f++){var p=r[u+f],m=i[u+f],b=r[u+f+s],g=i[u+f+s],v=l*b-h*g;g=l*g+h*b,b=v,r[u+f]=p+b,i[u+f]=m+g,r[u+f+s]=p-b,i[u+f+s]=m-g,f!==o&&(v=c*l-d*h,h=c*h+d*l,l=v)}},y.prototype.guessLen13b=function(e,t){var r=1|Math.max(t,e),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},y.prototype.conjugate=function(e,t,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=e[i];e[i]=e[r-i-1],e[r-i-1]=n,n=t[i],t[i]=-t[r-i-1],t[r-i-1]=-n}},y.prototype.normalize13b=function(e,t){for(var r=0,i=0;i<t/2;i++){var n=8192*Math.round(e[2*i+1]/t)+Math.round(e[2*i]/t)+r;e[i]=67108863&n,r=n<67108864?0:n/67108864|0}return e},y.prototype.convert13b=function(e,t,r,n){for(var a=0,s=0;s<t;s++)a+=0|e[s],r[2*s]=8191&a,a>>>=13,r[2*s+1]=8191&a,a>>>=13;for(s=2*t;s<n;++s)r[s]=0;i(0===a),i(!(-8192&a))},y.prototype.stub=function(e){for(var t=new Array(e),r=0;r<e;r++)t[r]=0;return t},y.prototype.mulp=function(e,t,r){var i=2*this.guessLen13b(e.length,t.length),n=this.makeRBT(i),a=this.stub(i),s=new Array(i),o=new Array(i),c=new Array(i),d=new Array(i),u=new Array(i),l=new Array(i),h=r.words;h.length=i,this.convert13b(e.words,e.length,s,i),this.convert13b(t.words,t.length,d,i),this.transform(s,a,o,c,i,n),this.transform(d,a,u,l,i,n);for(var f=0;f<i;f++){var p=o[f]*u[f]-c[f]*l[f];c[f]=o[f]*l[f]+c[f]*u[f],o[f]=p}return this.conjugate(o,c,i),this.transform(o,c,h,a,i,n),this.conjugate(h,a,i),this.normalize13b(h,i),r.negative=e.negative^t.negative,r.length=e.length+t.length,r._strip()},a.prototype.mul=function(e){var t=new a(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},a.prototype.mulf=function(e){var t=new a(null);return t.words=new Array(this.length+e.length),v(this,e,t)},a.prototype.imul=function(e){return this.clone().mulTo(e,this)},a.prototype.imuln=function(e){var t=e<0;t&&(e=-e),i("number"==typeof e),i(e<67108864);for(var r=0,n=0;n<this.length;n++){var a=(0|this.words[n])*e,s=(67108863&a)+(67108863&r);r>>=26,r+=a/67108864|0,r+=s>>>26,this.words[n]=67108863&s}return 0!==r&&(this.words[n]=r,this.length++),t?this.ineg():this},a.prototype.muln=function(e){return this.clone().imuln(e)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r<t.length;r++){var i=r/26|0,n=r%26;t[r]=e.words[i]>>>n&1}return t}(e);if(0===t.length)return new a(1);for(var r=this,i=0;i<t.length&&0===t[i];i++,r=r.sqr());if(++i<t.length)for(var n=r.sqr();i<t.length;i++,n=n.sqr())0!==t[i]&&(r=r.mul(n));return r},a.prototype.iushln=function(e){i("number"==typeof e&&e>=0);var t,r=e%26,n=(e-r)/26,a=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t<this.length;t++){var o=this.words[t]&a,c=(0|this.words[t])-o<<r;this.words[t]=c|s,s=o>>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==n){for(t=this.length-1;t>=0;t--)this.words[t+n]=this.words[t];for(t=0;t<n;t++)this.words[t]=0;this.length+=n}return this._strip()},a.prototype.ishln=function(e){return i(0===this.negative),this.iushln(e)},a.prototype.iushrn=function(e,t,r){var n;i("number"==typeof e&&e>=0),n=t?(t-t%26)/26:0;var a=e%26,s=Math.min((e-a)/26,this.length),o=67108863^67108863>>>a<<a,c=r;if(n-=s,n=Math.max(0,n),c){for(var d=0;d<s;d++)c.words[d]=this.words[d];c.length=s}if(0===s);else if(this.length>s)for(this.length-=s,d=0;d<this.length;d++)this.words[d]=this.words[d+s];else this.words[0]=0,this.length=1;var u=0;for(d=this.length-1;d>=0&&(0!==u||d>=n);d--){var l=0|this.words[d];this.words[d]=u<<26-a|l>>>a,u=l&o}return c&&0!==u&&(c.words[c.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(e,t,r){return i(0===this.negative),this.iushrn(e,t,r)},a.prototype.shln=function(e){return this.clone().ishln(e)},a.prototype.ushln=function(e){return this.clone().iushln(e)},a.prototype.shrn=function(e){return this.clone().ishrn(e)},a.prototype.ushrn=function(e){return this.clone().iushrn(e)},a.prototype.testn=function(e){i("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,n=1<<t;return!(this.length<=r)&&!!(this.words[r]&n)},a.prototype.imaskn=function(e){i("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var n=67108863^67108863>>>t<<t;this.words[this.length-1]&=n}return this._strip()},a.prototype.maskn=function(e){return this.clone().imaskn(e)},a.prototype.iaddn=function(e){return i("number"==typeof e),i(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<=e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},a.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},a.prototype.isubn=function(e){if(i("number"==typeof e),i(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this._strip()},a.prototype.addn=function(e){return this.clone().iaddn(e)},a.prototype.subn=function(e){return this.clone().isubn(e)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(e,t,r){var n,a,s=e.length+r;this._expand(s);var o=0;for(n=0;n<e.length;n++){a=(0|this.words[n+r])+o;var c=(0|e.words[n])*t;o=((a-=67108863&c)>>26)-(c/67108864|0),this.words[n+r]=67108863&a}for(;n<this.length-r;n++)o=(a=(0|this.words[n+r])+o)>>26,this.words[n+r]=67108863&a;if(0===o)return this._strip();for(i(-1===o),o=0,n=0;n<this.length;n++)o=(a=-(0|this.words[n])+o)>>26,this.words[n]=67108863&a;return this.negative=1,this._strip()},a.prototype._wordDiv=function(e,t){var r=(this.length,e.length),i=this.clone(),n=e,s=0|n.words[n.length-1];0!==(r=26-this._countBits(s))&&(n=n.ushln(r),i.iushln(r),s=0|n.words[n.length-1]);var o,c=i.length-n.length;if("mod"!==t){(o=new a(null)).length=c+1,o.words=new Array(o.length);for(var d=0;d<o.length;d++)o.words[d]=0}var u=i.clone()._ishlnsubmul(n,1,c);0===u.negative&&(i=u,o&&(o.words[c]=1));for(var l=c-1;l>=0;l--){var h=67108864*(0|i.words[n.length+l])+(0|i.words[n.length+l-1]);for(h=Math.min(h/s|0,67108863),i._ishlnsubmul(n,h,l);0!==i.negative;)h--,i.negative=0,i._ishlnsubmul(n,1,l),i.isZero()||(i.negative^=1);o&&(o.words[l]=h)}return o&&o._strip(),i._strip(),"div"!==t&&0!==r&&i.iushrn(r),{div:o||null,mod:i}},a.prototype.divmod=function(e,t,r){return i(!e.isZero()),this.isZero()?{div:new a(0),mod:new a(0)}:0!==this.negative&&0===e.negative?(o=this.neg().divmod(e,t),"mod"!==t&&(n=o.div.neg()),"div"!==t&&(s=o.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:n,mod:s}):0===this.negative&&0!==e.negative?(o=this.divmod(e.neg(),t),"mod"!==t&&(n=o.div.neg()),{div:n,mod:o.mod}):this.negative&e.negative?(o=this.neg().divmod(e.neg(),t),"div"!==t&&(s=o.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:o.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new a(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new a(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new a(this.modrn(e.words[0]))}:this._wordDiv(e,t);var n,s,o},a.prototype.div=function(e){return this.divmod(e,"div",!1).div},a.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},a.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},a.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),n=e.andln(1),a=r.cmp(i);return a<0||1===n&&0===a?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},a.prototype.modrn=function(e){var t=e<0;t&&(e=-e),i(e<=67108863);for(var r=(1<<26)%e,n=0,a=this.length-1;a>=0;a--)n=(r*n+(0|this.words[a]))%e;return t?-n:n},a.prototype.modn=function(e){return this.modrn(e)},a.prototype.idivn=function(e){var t=e<0;t&&(e=-e),i(e<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var a=(0|this.words[n])+67108864*r;this.words[n]=a/e|0,r=a%e}return this._strip(),t?this.ineg():this},a.prototype.divn=function(e){return this.clone().idivn(e)},a.prototype.egcd=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n=new a(1),s=new a(0),o=new a(0),c=new a(1),d=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++d;for(var u=r.clone(),l=t.clone();!t.isZero();){for(var h=0,f=1;!(t.words[0]&f)&&h<26;++h,f<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(l)),n.iushrn(1),s.iushrn(1);for(var p=0,m=1;!(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(o.isOdd()||c.isOdd())&&(o.iadd(u),c.isub(l)),o.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),n.isub(o),s.isub(c)):(r.isub(t),o.isub(n),c.isub(s))}return{a:o,b:c,gcd:r.iushln(d)}},a.prototype._invmp=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n,s=new a(1),o=new a(0),c=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var d=0,u=1;!(t.words[0]&u)&&d<26;++d,u<<=1);if(d>0)for(t.iushrn(d);d-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var l=0,h=1;!(r.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(r.iushrn(l);l-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(o)):(r.isub(t),o.isub(s))}return(n=0===t.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(e),n},a.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var i=0;t.isEven()&&r.isEven();i++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=t.cmp(r);if(n<0){var a=t;t=r,r=a}else if(0===n||0===r.cmpn(1))break;t.isub(r)}return r.iushln(i)},a.prototype.invm=function(e){return this.egcd(e).a.umod(e)},a.prototype.isEven=function(){return!(1&this.words[0])},a.prototype.isOdd=function(){return!(1&~this.words[0])},a.prototype.andln=function(e){return this.words[0]&e},a.prototype.bincn=function(e){i("number"==typeof e);var t=e%26,r=(e-t)/26,n=1<<t;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var a=n,s=r;0!==a&&s<this.length;s++){var o=0|this.words[s];a=(o+=a)>>>26,o&=67108863,this.words[s]=o}return 0!==a&&(this.words[s]=a,this.length++),this},a.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},a.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),i(e<=67108863,"Number is too big");var n=0|this.words[0];t=n===e?0:n<e?-1:1}return 0!==this.negative?0|-t:t},a.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},a.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|e.words[r];if(i!==n){i<n?t=-1:i>n&&(t=1);break}}return t},a.prototype.gtn=function(e){return 1===this.cmpn(e)},a.prototype.gt=function(e){return 1===this.cmp(e)},a.prototype.gten=function(e){return this.cmpn(e)>=0},a.prototype.gte=function(e){return this.cmp(e)>=0},a.prototype.ltn=function(e){return-1===this.cmpn(e)},a.prototype.lt=function(e){return-1===this.cmp(e)},a.prototype.lten=function(e){return this.cmpn(e)<=0},a.prototype.lte=function(e){return this.cmp(e)<=0},a.prototype.eqn=function(e){return 0===this.cmpn(e)},a.prototype.eq=function(e){return 0===this.cmp(e)},a.red=function(e){return new M(e)},a.prototype.toRed=function(e){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(e){return this.red=e,this},a.prototype.forceRed=function(e){return i(!this.red,"Already a number in reduction context"),this._forceRed(e)},a.prototype.redAdd=function(e){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},a.prototype.redIAdd=function(e){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},a.prototype.redSub=function(e){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},a.prototype.redISub=function(e){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},a.prototype.redShl=function(e){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},a.prototype.redMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},a.prototype.redIMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},a.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(e){return i(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var _={k256:null,p224:null,p192:null,p25519:null};function w(e,t){this.name=e,this.p=new a(t,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function S(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function R(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(e){if("string"==typeof e){var t=a._prime(e);this.m=t.p,this.prime=t}else i(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){M.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var e=new a(null);return e.words=new Array(Math.ceil(this.n/13)),e},w.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var i=t<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(e,t){e.iushrn(this.n,0,t)},w.prototype.imulK=function(e){return e.imul(this.k)},n(S,w),S.prototype.split=function(e,t){for(var r=4194303,i=Math.min(e.length,9),n=0;n<i;n++)t.words[n]=e.words[n];if(t.length=i,e.length<=9)return e.words[0]=0,void(e.length=1);var a=e.words[9];for(t.words[t.length++]=a&r,n=10;n<e.length;n++){var s=0|e.words[n];e.words[n-10]=(s&r)<<4|a>>>22,a=s}a>>>=22,e.words[n-10]=a,0===a&&e.length>10?e.length-=10:e.length-=9},S.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r<e.length;r++){var i=0|e.words[r];t+=977*i,e.words[r]=67108863&t,t=64*i+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},n(k,w),n(R,w),n(P,w),P.prototype.imulK=function(e){for(var t=0,r=0;r<e.length;r++){var i=19*(0|e.words[r])+t,n=67108863&i;i>>>=26,e.words[r]=n,t=i}return 0!==t&&(e.words[e.length++]=t),e},a._prime=function(e){if(_[e])return _[e];var t;if("k256"===e)t=new S;else if("p224"===e)t=new k;else if("p192"===e)t=new R;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new P}return _[e]=t,t},M.prototype._verify1=function(e){i(0===e.negative,"red works only with positives"),i(e.red,"red works only with red numbers")},M.prototype._verify2=function(e,t){i(!(e.negative|t.negative),"red works only with positives"),i(e.red&&e.red===t.red,"red works only with red numbers")},M.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},M.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},M.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},M.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},M.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},M.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},M.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},M.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},M.prototype.isqr=function(e){return this.imul(e,e.clone())},M.prototype.sqr=function(e){return this.mul(e,e)},M.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(i(t%2==1),3===t){var r=this.m.add(new a(1)).iushrn(2);return this.pow(e,r)}for(var n=this.m.subn(1),s=0;!n.isZero()&&0===n.andln(1);)s++,n.iushrn(1);i(!n.isZero());var o=new a(1).toRed(this),c=o.redNeg(),d=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new a(2*u*u).toRed(this);0!==this.pow(u,d).cmp(c);)u.redIAdd(c);for(var l=this.pow(u,n),h=this.pow(e,n.addn(1).iushrn(1)),f=this.pow(e,n),p=s;0!==f.cmp(o);){for(var m=f,b=0;0!==m.cmp(o);b++)m=m.redSqr();i(b<p);var g=this.pow(l,new a(1).iushln(p-b-1));h=h.redMul(g),l=g.redSqr(),f=f.redMul(l),p=b}return h},M.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},M.prototype.pow=function(e,t){if(t.isZero())return new a(1).toRed(this);if(0===t.cmpn(1))return e.clone();var r=new Array(16);r[0]=new a(1).toRed(this),r[1]=e;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],e);var n=r[0],s=0,o=0,c=t.bitLength()%26;for(0===c&&(c=26),i=t.length-1;i>=0;i--){for(var d=t.words[i],u=c-1;u>=0;u--){var l=d>>u&1;n!==r[0]&&(n=this.sqr(n)),0!==l||0!==s?(s<<=1,s|=l,(4===++o||0===i&&0===u)&&(n=this.mul(n,r[s]),o=0,s=0)):o=0}c=26}return n},M.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},M.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},a.mont=function(e){return new E(e)},n(E,M),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),a=n;return n.cmp(this.m)>=0?a=n.isub(this.m):n.cmpn(0)<0&&(a=n.iadd(this.m)),a._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new a(0)._forceRed(this);var r=e.mul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:63}],61:[function(e,t,r){var i,n;i=this,n=function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={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){"use strict";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),a=e.getVersionPrecision(r),s=Math.max(n,a),o=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&&(o=s-Math.min(n,a)),s-=1;s>=o;){if(c[0][s]>c[1][s])return 1;if(c[0][s]===c[1][s]){if(s===o)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,a=new Array(n>1?n-1:0),s=1;s<n;s++)a[s-1]=arguments[s];if(Object.assign)return Object.assign.apply(Object,[e].concat(a));var o=function(){var e=a[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){i[t]=e[t]}))};for(t=0,r=a.length;t<r;t+=1)o();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){"use strict";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){"use strict";t.__esModule=!0,t.default=void 0;var i,n=(i=r(91))&&i.__esModule?i:{default:i},a=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 o=function(){function e(){}var t,r;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,(r=[{key:"BROWSER_MAP",get:function(){return a.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return a.ENGINE_MAP}},{key:"OS_MAP",get:function(){return a.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return a.PLATFORMS_MAP}}])&&s(t,r),e}();t.default=o,e.exports=t.default},91:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var i=c(r(92)),n=c(r(93)),a=c(r(94)),s=c(r(95)),o=c(r(17));function c(e){return e&&e.__esModule?e:{default:e}}var d=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=o.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=o.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=o.default.find(a.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=o.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 o.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},i=0,n={},a=0;if(Object.keys(e).forEach((function(t){var s=e[t];"string"==typeof s?(n[t]=s,a+=1):"object"==typeof s&&(r[t]=s,i+=1)})),i>0){var s=Object.keys(r),c=o.default.find(s,(function(e){return t.isOS(e)}));if(c){var d=this.satisfies(r[c]);if(void 0!==d)return d}var u=o.default.find(s,(function(e){return t.isPlatform(e)}));if(u){var l=this.satisfies(r[u]);if(void 0!==l)return l}}if(a>0){var h=Object.keys(n),f=o.default.find(h,(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=o.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(o.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=d,e.exports=t.default},92:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},a=/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(a,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=n.default.getFirstMatch(a,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(a,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=n.default.getFirstMatch(a,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(a,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(a,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(a,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(a,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=n.default.getFirstMatch(a,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(a,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(a,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=n.default.getFirstMatch(a,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(a,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(a,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(a,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(a,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(a,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(a,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(a,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(a,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(a,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(a,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(a,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(a,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(a,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=n.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=n.default.getFirstMatch(a,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){"use strict";t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},a=r(18),s=[{test:[/Roku\/DVP/],describe:function(e){var t=n.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:a.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:a.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:a.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:a.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:a.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:a.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:a.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:a.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:a.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=n.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:a.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=n.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:a.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:a.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:a.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=n.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:a.OS_MAP.PlayStation4,version:t}}}];t.default=s,e.exports=t.default},94:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},a=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:a.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:a.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:a.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:a.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:a.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:a.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:a.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:a.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:a.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:a.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:a.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:a.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.tv}}}];t.default=s,e.exports=t.default},95:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},a=r(18),s=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:a.ENGINE_MAP.Blink};var t=n.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:a.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:a.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:a.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:a.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:a.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:a.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}})},"object"==typeof r&&"object"==typeof t?t.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof r?r.bowser=n():i.bowser=n()},{}],62:[function(e,t,r){var i;function n(e){this.rand=e}if(t.exports=function(e){return i||(i=new n(null)),i.generate(e)},t.exports.Rand=n,n.prototype.generate=function(e){return this._rand(e)},n.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r<t.length;r++)t[r]=this.rand.getByte();return t},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?n.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?n.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:"object"==typeof window&&(n.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var a=e("crypto");if("function"!=typeof a.randomBytes)throw new Error("Not supported");n.prototype._rand=function(e){return a.randomBytes(e)}}catch(e){}},{crypto:63}],63:[function(e,t,r){},{}],64:[function(e,t,r){var i=e("safe-buffer").Buffer;function n(e){i.isBuffer(e)||(e=i.from(e));for(var t=e.length/4|0,r=new Array(t),n=0;n<t;n++)r[n]=e.readUInt32BE(4*n);return r}function a(e){for(;0<e.length;e++)e[0]=0}function s(e,t,r,i,n){for(var a,s,o,c,d=r[0],u=r[1],l=r[2],h=r[3],f=e[0]^t[0],p=e[1]^t[1],m=e[2]^t[2],b=e[3]^t[3],g=4,v=1;v<n;v++)a=d[f>>>24]^u[p>>>16&255]^l[m>>>8&255]^h[255&b]^t[g++],s=d[p>>>24]^u[m>>>16&255]^l[b>>>8&255]^h[255&f]^t[g++],o=d[m>>>24]^u[b>>>16&255]^l[f>>>8&255]^h[255&p]^t[g++],c=d[b>>>24]^u[f>>>16&255]^l[p>>>8&255]^h[255&m]^t[g++],f=a,p=s,m=o,b=c;return a=(i[f>>>24]<<24|i[p>>>16&255]<<16|i[m>>>8&255]<<8|i[255&b])^t[g++],s=(i[p>>>24]<<24|i[m>>>16&255]<<16|i[b>>>8&255]<<8|i[255&f])^t[g++],o=(i[m>>>24]<<24|i[b>>>16&255]<<16|i[f>>>8&255]<<8|i[255&p])^t[g++],c=(i[b>>>24]<<24|i[f>>>16&255]<<16|i[p>>>8&255]<<8|i[255&m])^t[g++],[a>>>=0,s>>>=0,o>>>=0,c>>>=0]}var o=[0,1,2,4,8,16,32,64,128,27,54],c=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],i=[],n=[[],[],[],[]],a=[[],[],[],[]],s=0,o=0,c=0;c<256;++c){var d=o^o<<1^o<<2^o<<3^o<<4;d=d>>>8^255&d^99,r[s]=d,i[d]=s;var u=e[s],l=e[u],h=e[l],f=257*e[d]^16843008*d;n[0][s]=f<<24|f>>>8,n[1][s]=f<<16|f>>>16,n[2][s]=f<<8|f>>>24,n[3][s]=f,f=16843009*h^65537*l^257*u^16843008*s,a[0][d]=f<<24|f>>>8,a[1][d]=f<<16|f>>>16,a[2][d]=f<<8|f>>>24,a[3][d]=f,0===s?s=o=1:(s=u^e[e[e[h^u]]],o^=e[e[o]])}return{SBOX:r,INV_SBOX:i,SUB_MIX:n,INV_SUB_MIX:a}}();function d(e){this._key=n(e),this._reset()}d.blockSize=16,d.keySize=32,d.prototype.blockSize=d.blockSize,d.prototype.keySize=d.keySize,d.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,i=4*(r+1),n=[],a=0;a<t;a++)n[a]=e[a];for(a=t;a<i;a++){var s=n[a-1];a%t==0?(s=s<<8|s>>>24,s=c.SBOX[s>>>24]<<24|c.SBOX[s>>>16&255]<<16|c.SBOX[s>>>8&255]<<8|c.SBOX[255&s],s^=o[a/t|0]<<24):t>6&&a%t==4&&(s=c.SBOX[s>>>24]<<24|c.SBOX[s>>>16&255]<<16|c.SBOX[s>>>8&255]<<8|c.SBOX[255&s]),n[a]=n[a-t]^s}for(var d=[],u=0;u<i;u++){var l=i-u,h=n[l-(u%4?0:4)];d[u]=u<4||l<=4?h:c.INV_SUB_MIX[0][c.SBOX[h>>>24]]^c.INV_SUB_MIX[1][c.SBOX[h>>>16&255]]^c.INV_SUB_MIX[2][c.SBOX[h>>>8&255]]^c.INV_SUB_MIX[3][c.SBOX[255&h]]}this._nRounds=r,this._keySchedule=n,this._invKeySchedule=d},d.prototype.encryptBlockRaw=function(e){return s(e=n(e),this._keySchedule,c.SUB_MIX,c.SBOX,this._nRounds)},d.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=i.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},d.prototype.decryptBlock=function(e){var t=(e=n(e))[1];e[1]=e[3],e[3]=t;var r=s(e,this._invKeySchedule,c.INV_SUB_MIX,c.INV_SBOX,this._nRounds),a=i.allocUnsafe(16);return a.writeUInt32BE(r[0],0),a.writeUInt32BE(r[3],4),a.writeUInt32BE(r[2],8),a.writeUInt32BE(r[1],12),a},d.prototype.scrub=function(){a(this._keySchedule),a(this._invKeySchedule),a(this._key)},t.exports.AES=d},{"safe-buffer":284}],65:[function(e,t,r){var i=e("./aes"),n=e("safe-buffer").Buffer,a=e("cipher-base"),s=e("inherits"),o=e("./ghash"),c=e("buffer-xor"),d=e("./incr32");function u(e,t,r,s){a.call(this);var c=n.alloc(4,0);this._cipher=new i.AES(t);var u=this._cipher.encryptBlock(c);this._ghash=new o(u),r=function(e,t,r){if(12===t.length)return e._finID=n.concat([t,n.from([0,0,0,1])]),n.concat([t,n.from([0,0,0,2])]);var i=new o(r),a=t.length,s=a%16;i.update(t),s&&(s=16-s,i.update(n.alloc(s,0))),i.update(n.alloc(8,0));var c=8*a,u=n.alloc(8);u.writeUIntBE(c,0,8),i.update(u),e._finID=i.state;var l=n.from(e._finID);return d(l),l}(this,r,u),this._prev=n.from(r),this._cache=n.allocUnsafe(0),this._secCache=n.allocUnsafe(0),this._decrypt=s,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}s(u,a),u.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=n.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},u.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=c(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var i=Math.min(e.length,t.length),n=0;n<i;++n)r+=e[n]^t[n];return r}(e,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=e,this._cipher.scrub()},u.prototype.getAuthTag=function(){if(this._decrypt||!n.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},u.prototype.setAuthTag=function(e){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=e},u.prototype.setAAD=function(e){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(e),this._alen+=e.length},t.exports=u},{"./aes":64,"./ghash":69,"./incr32":70,"buffer-xor":93,"cipher-base":95,inherits:174,"safe-buffer":284}],66:[function(e,t,r){var i=e("./encrypter"),n=e("./decrypter"),a=e("./modes/list.json");r.createCipher=r.Cipher=i.createCipher,r.createCipheriv=r.Cipheriv=i.createCipheriv,r.createDecipher=r.Decipher=n.createDecipher,r.createDecipheriv=r.Decipheriv=n.createDecipheriv,r.listCiphers=r.getCiphers=function(){return Object.keys(a)}},{"./decrypter":67,"./encrypter":68,"./modes/list.json":78}],67:[function(e,t,r){var i=e("./authCipher"),n=e("safe-buffer").Buffer,a=e("./modes"),s=e("./streamCipher"),o=e("cipher-base"),c=e("./aes"),d=e("evp_bytestokey");function u(e,t,r){o.call(this),this._cache=new l,this._last=void 0,this._cipher=new c.AES(t),this._prev=n.from(r),this._mode=e,this._autopadding=!0}function l(){this.cache=n.allocUnsafe(0)}function h(e,t,r){var o=a[e.toLowerCase()];if(!o)throw new TypeError("invalid suite type");if("string"==typeof r&&(r=n.from(r)),"GCM"!==o.mode&&r.length!==o.iv)throw new TypeError("invalid iv length "+r.length);if("string"==typeof t&&(t=n.from(t)),t.length!==o.key/8)throw new TypeError("invalid key length "+t.length);return"stream"===o.type?new s(o.module,t,r,!0):"auth"===o.type?new i(o.module,t,r,!0):new u(o.module,t,r)}e("inherits")(u,o),u.prototype._update=function(e){var t,r;this._cache.add(e);for(var i=[];t=this._cache.get(this._autopadding);)r=this._mode.decrypt(this,t),i.push(r);return n.concat(i)},u.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return function(e){var t=e[15];if(t<1||t>16)throw new Error("unable to decrypt data");var r=-1;for(;++r<t;)if(e[r+(16-t)]!==t)throw new Error("unable to decrypt data");if(16===t)return;return e.slice(0,16-t)}(this._mode.decrypt(this,e));if(e)throw new Error("data not multiple of block length")},u.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=n.concat([this.cache,e])},l.prototype.get=function(e){var t;if(e){if(this.cache.length>16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},l.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=a[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var i=d(t,!1,r.key,r.iv);return h(e,i.key,i.iv)},r.createDecipheriv=h},{"./aes":64,"./authCipher":65,"./modes":77,"./streamCipher":80,"cipher-base":95,evp_bytestokey:156,inherits:174,"safe-buffer":284}],68:[function(e,t,r){var i=e("./modes"),n=e("./authCipher"),a=e("safe-buffer").Buffer,s=e("./streamCipher"),o=e("cipher-base"),c=e("./aes"),d=e("evp_bytestokey");function u(e,t,r){o.call(this),this._cache=new h,this._cipher=new c.AES(t),this._prev=a.from(r),this._mode=e,this._autopadding=!0}e("inherits")(u,o),u.prototype._update=function(e){var t,r;this._cache.add(e);for(var i=[];t=this._cache.get();)r=this._mode.encrypt(this,t),i.push(r);return a.concat(i)};var l=a.alloc(16,16);function h(){this.cache=a.allocUnsafe(0)}function f(e,t,r){var o=i[e.toLowerCase()];if(!o)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=a.from(t)),t.length!==o.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=a.from(r)),"GCM"!==o.mode&&r.length!==o.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===o.type?new s(o.module,t,r):"auth"===o.type?new n(o.module,t,r):new u(o.module,t,r)}u.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(l))throw this._cipher.scrub(),new Error("data not multiple of block length")},u.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},h.prototype.add=function(e){this.cache=a.concat([this.cache,e])},h.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},h.prototype.flush=function(){for(var e=16-this.cache.length,t=a.allocUnsafe(e),r=-1;++r<e;)t.writeUInt8(e,r);return a.concat([this.cache,t])},r.createCipheriv=f,r.createCipher=function(e,t){var r=i[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=d(t,!1,r.key,r.iv);return f(e,n.key,n.iv)}},{"./aes":64,"./authCipher":65,"./modes":77,"./streamCipher":80,"cipher-base":95,evp_bytestokey:156,inherits:174,"safe-buffer":284}],69:[function(e,t,r){var i=e("safe-buffer").Buffer,n=i.alloc(16,0);function a(e){var t=i.allocUnsafe(16);return t.writeUInt32BE(e[0]>>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function s(e){this.h=e,this.state=i.alloc(16,0),this.cache=i.allocUnsafe(0)}s.prototype.ghash=function(e){for(var t=-1;++t<e.length;)this.state[t]^=e[t];this._multiply()},s.prototype._multiply=function(){for(var e,t,r,i=[(e=this.h).readUInt32BE(0),e.readUInt32BE(4),e.readUInt32BE(8),e.readUInt32BE(12)],n=[0,0,0,0],s=-1;++s<128;){for(!!(this.state[~~(s/8)]&1<<7-s%8)&&(n[0]^=i[0],n[1]^=i[1],n[2]^=i[2],n[3]^=i[3]),r=!!(1&i[3]),t=3;t>0;t--)i[t]=i[t]>>>1|(1&i[t-1])<<31;i[0]=i[0]>>>1,r&&(i[0]=i[0]^225<<24)}this.state=a(n)},s.prototype.update=function(e){var t;for(this.cache=i.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},s.prototype.final=function(e,t){return this.cache.length&&this.ghash(i.concat([this.cache,n],16)),this.ghash(a([0,e,0,t])),this.state},t.exports=s},{"safe-buffer":284}],70:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],71:[function(e,t,r){var i=e("buffer-xor");r.encrypt=function(e,t){var r=i(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var n=e._cipher.decryptBlock(t);return i(n,r)}},{"buffer-xor":93}],72:[function(e,t,r){var i=e("safe-buffer").Buffer,n=e("buffer-xor");function a(e,t,r){var a=t.length,s=n(t,e._cache);return e._cache=e._cache.slice(a),e._prev=i.concat([e._prev,r?t:s]),s}r.encrypt=function(e,t,r){for(var n,s=i.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=i.allocUnsafe(0)),!(e._cache.length<=t.length)){s=i.concat([s,a(e,t,r)]);break}n=e._cache.length,s=i.concat([s,a(e,t.slice(0,n),r)]),t=t.slice(n)}return s}},{"buffer-xor":93,"safe-buffer":284}],73:[function(e,t,r){var i=e("safe-buffer").Buffer;function n(e,t,r){for(var i,n,s=-1,o=0;++s<8;)i=t&1<<7-s?128:0,o+=(128&(n=e._cipher.encryptBlock(e._prev)[0]^i))>>s%8,e._prev=a(e._prev,r?i:n);return o}function a(e,t){var r=e.length,n=-1,a=i.allocUnsafe(e.length);for(e=i.concat([e,i.from([t])]);++n<r;)a[n]=e[n]<<1|e[n+1]>>7;return a}r.encrypt=function(e,t,r){for(var a=t.length,s=i.allocUnsafe(a),o=-1;++o<a;)s[o]=n(e,t[o],r);return s}},{"safe-buffer":284}],74:[function(e,t,r){var i=e("safe-buffer").Buffer;function n(e,t,r){var n=e._cipher.encryptBlock(e._prev)[0]^t;return e._prev=i.concat([e._prev.slice(1),i.from([r?t:n])]),n}r.encrypt=function(e,t,r){for(var a=t.length,s=i.allocUnsafe(a),o=-1;++o<a;)s[o]=n(e,t[o],r);return s}},{"safe-buffer":284}],75:[function(e,t,r){var i=e("buffer-xor"),n=e("safe-buffer").Buffer,a=e("../incr32");function s(e){var t=e._cipher.encryptBlockRaw(e._prev);return a(e._prev),t}r.encrypt=function(e,t){var r=Math.ceil(t.length/16),a=e._cache.length;e._cache=n.concat([e._cache,n.allocUnsafe(16*r)]);for(var o=0;o<r;o++){var c=s(e),d=a+16*o;e._cache.writeUInt32BE(c[0],d+0),e._cache.writeUInt32BE(c[1],d+4),e._cache.writeUInt32BE(c[2],d+8),e._cache.writeUInt32BE(c[3],d+12)}var u=e._cache.slice(0,t.length);return e._cache=e._cache.slice(t.length),i(t,u)}},{"../incr32":70,"buffer-xor":93,"safe-buffer":284}],76:[function(e,t,r){r.encrypt=function(e,t){return e._cipher.encryptBlock(t)},r.decrypt=function(e,t){return e._cipher.decryptBlock(t)}},{}],77:[function(e,t,r){var i={ECB:e("./ecb"),CBC:e("./cbc"),CFB:e("./cfb"),CFB8:e("./cfb8"),CFB1:e("./cfb1"),OFB:e("./ofb"),CTR:e("./ctr"),GCM:e("./ctr")},n=e("./list.json");for(var a in n)n[a].module=i[n[a].mode];t.exports=n},{"./cbc":71,"./cfb":72,"./cfb1":73,"./cfb8":74,"./ctr":75,"./ecb":76,"./list.json":78,"./ofb":79}],78:[function(e,t,r){t.exports={"aes-128-ecb":{cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},"aes-192-ecb":{cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},"aes-256-ecb":{cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},"aes-128-cbc":{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},"aes-192-cbc":{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},"aes-256-cbc":{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},aes128:{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},aes192:{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},aes256:{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},"aes-128-cfb":{cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},"aes-192-cfb":{cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},"aes-256-cfb":{cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},"aes-128-cfb8":{cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},"aes-192-cfb8":{cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},"aes-256-cfb8":{cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},"aes-128-cfb1":{cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},"aes-192-cfb1":{cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},"aes-256-cfb1":{cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},"aes-128-ofb":{cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},"aes-192-ofb":{cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},"aes-256-ofb":{cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},"aes-128-ctr":{cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},"aes-192-ctr":{cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},"aes-256-ctr":{cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},"aes-128-gcm":{cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},"aes-192-gcm":{cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},"aes-256-gcm":{cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}}},{}],79:[function(e,t,r){(function(t){(function(){var i=e("buffer-xor");function n(e){return e._prev=e._cipher.encryptBlock(e._prev),e._prev}r.encrypt=function(e,r){for(;e._cache.length<r.length;)e._cache=t.concat([e._cache,n(e)]);var a=e._cache.slice(0,r.length);return e._cache=e._cache.slice(r.length),i(r,a)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:94,"buffer-xor":93}],80:[function(e,t,r){var i=e("./aes"),n=e("safe-buffer").Buffer,a=e("cipher-base");function s(e,t,r,s){a.call(this),this._cipher=new i.AES(t),this._prev=n.from(r),this._cache=n.allocUnsafe(0),this._secCache=n.allocUnsafe(0),this._decrypt=s,this._mode=e}e("inherits")(s,a),s.prototype._update=function(e){return this._mode.encrypt(this,e,this._decrypt)},s.prototype._final=function(){this._cipher.scrub()},t.exports=s},{"./aes":64,"cipher-base":95,inherits:174,"safe-buffer":284}],81:[function(e,t,r){var i=e("browserify-des"),n=e("browserify-aes/browser"),a=e("browserify-aes/modes"),s=e("browserify-des/modes"),o=e("evp_bytestokey");function c(e,t,r){if(e=e.toLowerCase(),a[e])return n.createCipheriv(e,t,r);if(s[e])return new i({key:t,iv:r,mode:e});throw new TypeError("invalid suite type")}function d(e,t,r){if(e=e.toLowerCase(),a[e])return n.createDecipheriv(e,t,r);if(s[e])return new i({key:t,iv:r,mode:e,decrypt:!0});throw new TypeError("invalid suite type")}r.createCipher=r.Cipher=function(e,t){var r,i;if(e=e.toLowerCase(),a[e])r=a[e].key,i=a[e].iv;else{if(!s[e])throw new TypeError("invalid suite type");r=8*s[e].key,i=s[e].iv}var n=o(t,!1,r,i);return c(e,n.key,n.iv)},r.createCipheriv=r.Cipheriv=c,r.createDecipher=r.Decipher=function(e,t){var r,i;if(e=e.toLowerCase(),a[e])r=a[e].key,i=a[e].iv;else{if(!s[e])throw new TypeError("invalid suite type");r=8*s[e].key,i=s[e].iv}var n=o(t,!1,r,i);return d(e,n.key,n.iv)},r.createDecipheriv=r.Decipheriv=d,r.listCiphers=r.getCiphers=function(){return Object.keys(s).concat(n.getCiphers())}},{"browserify-aes/browser":66,"browserify-aes/modes":77,"browserify-des":82,"browserify-des/modes":83,evp_bytestokey:156}],82:[function(e,t,r){var i=e("cipher-base"),n=e("des.js"),a=e("inherits"),s=e("safe-buffer").Buffer,o={"des-ede3-cbc":n.CBC.instantiate(n.EDE),"des-ede3":n.EDE,"des-ede-cbc":n.CBC.instantiate(n.EDE),"des-ede":n.EDE,"des-cbc":n.CBC.instantiate(n.DES),"des-ecb":n.DES};function c(e){i.call(this);var t,r=e.mode.toLowerCase(),n=o[r];t=e.decrypt?"decrypt":"encrypt";var a=e.key;s.isBuffer(a)||(a=s.from(a)),"des-ede"!==r&&"des-ede-cbc"!==r||(a=s.concat([a,a.slice(0,8)]));var c=e.iv;s.isBuffer(c)||(c=s.from(c)),this._des=n.create({key:a,iv:c,type:t})}o.des=o["des-cbc"],o.des3=o["des-ede3-cbc"],t.exports=c,a(c,i),c.prototype._update=function(e){return s.from(this._des.update(e))},c.prototype._final=function(){return s.from(this._des.final())}},{"cipher-base":95,"des.js":106,inherits:174,"safe-buffer":284}],83:[function(e,t,r){r["des-ecb"]={key:8,iv:0},r["des-cbc"]=r.des={key:8,iv:8},r["des-ede3-cbc"]=r.des3={key:24,iv:8},r["des-ede3"]={key:24,iv:0},r["des-ede-cbc"]={key:16,iv:8},r["des-ede"]={key:16,iv:0}},{}],84:[function(e,t,r){(function(r){(function(){var i=e("bn.js"),n=e("randombytes");function a(e){var t,r=e.modulus.byteLength();do{t=new i(n(r))}while(t.cmp(e.modulus)>=0||!t.umod(e.prime1)||!t.umod(e.prime2));return t}function s(e,t){var n=function(e){var t=a(e);return{blinder:t.toRed(i.mont(e.modulus)).redPow(new i(e.publicExponent)).fromRed(),unblinder:t.invm(e.modulus)}}(t),s=t.modulus.byteLength(),o=new i(e).mul(n.blinder).umod(t.modulus),c=o.toRed(i.mont(t.prime1)),d=o.toRed(i.mont(t.prime2)),u=t.coefficient,l=t.prime1,h=t.prime2,f=c.redPow(t.exponent1).fromRed(),p=d.redPow(t.exponent2).fromRed(),m=f.isub(p).imul(u).umod(l).imul(h);return p.iadd(m).imul(n.unblinder).umod(t.modulus).toArrayLike(r,"be",s)}s.getr=a,t.exports=s}).call(this)}).call(this,e("buffer").Buffer)},{"bn.js":60,buffer:94,randombytes:266}],85:[function(e,t,r){"use strict";t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":86}],86:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],87:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],88:[function(e,t,r){"use strict";var i=e("safe-buffer").Buffer,n=e("create-hash"),a=e("readable-stream"),s=e("inherits"),o=e("./sign"),c=e("./verify"),d=e("./algorithms.json");function u(e){a.Writable.call(this);var t=d[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function l(e){a.Writable.call(this);var t=d[e];if(!t)throw new Error("Unknown message digest");this._hash=n(t.hash),this._tag=t.id,this._signType=t.sign}function h(e){return new u(e)}function f(e){return new l(e)}Object.keys(d).forEach((function(e){d[e].id=i.from(d[e].id,"hex"),d[e.toLowerCase()]=d[e]})),s(u,a.Writable),u.prototype._write=function(e,t,r){this._hash.update(e),r()},u.prototype.update=function(e,t){return this._hash.update("string"==typeof e?i.from(e,t):e),this},u.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),i=o(r,e,this._hashType,this._signType,this._tag);return t?i.toString(t):i},s(l,a.Writable),l.prototype._write=function(e,t,r){this._hash.update(e),r()},l.prototype.update=function(e,t){return this._hash.update("string"==typeof e?i.from(e,t):e),this},l.prototype.verify=function(e,t,r){var n="string"==typeof t?i.from(t,r):t;this.end();var a=this._hash.digest();return c(n,a,e,this._signType,this._tag)},t.exports={Sign:h,Verify:f,createSign:h,createVerify:f}},{"./algorithms.json":86,"./sign":89,"./verify":90,"create-hash":99,inherits:174,"readable-stream":280,"safe-buffer":284}],89:[function(e,t,r){"use strict";var i=e("safe-buffer").Buffer,n=e("create-hmac"),a=e("browserify-rsa"),s=e("elliptic").ec,o=e("bn.js"),c=e("parse-asn1"),d=e("./curves.json");function u(e,t,r,a){if((e=i.from(e.toArray())).length<t.byteLength()){var s=i.alloc(t.byteLength()-e.length);e=i.concat([s,e])}var o=r.length,c=function(e,t){e=l(e,t),e=e.mod(t);var r=i.from(e.toArray());if(r.length<t.byteLength()){var n=i.alloc(t.byteLength()-r.length);r=i.concat([n,r])}return r}(r,t),d=i.alloc(o);d.fill(1);var u=i.alloc(o);return u=n(a,u).update(d).update(i.from([0])).update(e).update(c).digest(),d=n(a,u).update(d).digest(),{k:u=n(a,u).update(d).update(i.from([1])).update(e).update(c).digest(),v:d=n(a,u).update(d).digest()}}function l(e,t){var r=new o(e),i=(e.length<<3)-t.bitLength();return i>0&&r.ishrn(i),r}function h(e,t,r){var a,s;do{for(a=i.alloc(0);8*a.length<e.bitLength();)t.v=n(r,t.k).update(t.v).digest(),a=i.concat([a,t.v]);s=l(a,e),t.k=n(r,t.k).update(t.v).update(i.from([0])).digest(),t.v=n(r,t.k).update(t.v).digest()}while(-1!==s.cmp(e));return s}function f(e,t,r,i){return e.toRed(o.mont(r)).redPow(t).fromRed().mod(i)}t.exports=function(e,t,r,n,p){var m=c(t);if(m.curve){if("ecdsa"!==n&&"ecdsa/rsa"!==n)throw new Error("wrong private key type");return function(e,t){var r=d[t.curve.join(".")];if(!r)throw new Error("unknown curve "+t.curve.join("."));var n=new s(r).keyFromPrivate(t.privateKey),a=n.sign(e);return i.from(a.toDER())}(e,m)}if("dsa"===m.type){if("dsa"!==n)throw new Error("wrong private key type");return function(e,t,r){var n,a=t.params.priv_key,s=t.params.p,c=t.params.q,d=t.params.g,p=new o(0),m=l(e,c).mod(c),b=!1,g=u(a,c,e,r);for(;!1===b;)p=f(d,n=h(c,g,r),s,c),0===(b=n.invm(c).imul(m.add(a.mul(p))).mod(c)).cmpn(0)&&(b=!1,p=new o(0));return function(e,t){e=e.toArray(),t=t.toArray(),128&e[0]&&(e=[0].concat(e));128&t[0]&&(t=[0].concat(t));var r=e.length+t.length+4,n=[48,r,2,e.length];return n=n.concat(e,[2,t.length],t),i.from(n)}(p,b)}(e,m,r)}if("rsa"!==n&&"ecdsa/rsa"!==n)throw new Error("wrong private key type");if(void 0!==t.padding&&1!==t.padding)throw new Error("illegal or unsupported padding mode");e=i.concat([p,e]);for(var b=m.modulus.byteLength(),g=[0,1];e.length+g.length+1<b;)g.push(255);g.push(0);for(var v=-1;++v<e.length;)g.push(e[v]);return a(g,m)},t.exports.getKey=u,t.exports.makeKey=h},{"./curves.json":87,"bn.js":60,"browserify-rsa":84,"create-hmac":101,elliptic:119,"parse-asn1":247,"safe-buffer":284}],90:[function(e,t,r){"use strict";var i=e("safe-buffer").Buffer,n=e("bn.js"),a=e("elliptic").ec,s=e("parse-asn1"),o=e("./curves.json");function c(e,t){if(e.cmpn(0)<=0)throw new Error("invalid sig");if(e.cmp(t)>=0)throw new Error("invalid sig")}t.exports=function(e,t,r,d,u){var l=s(r);if("ec"===l.type){if("ecdsa"!==d&&"ecdsa/rsa"!==d)throw new Error("wrong public key type");return function(e,t,r){var i=o[r.data.algorithm.curve.join(".")];if(!i)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var n=new a(i),s=r.data.subjectPrivateKey.data;return n.verify(t,e,s)}(e,t,l)}if("dsa"===l.type){if("dsa"!==d)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,a=r.data.q,o=r.data.g,d=r.data.pub_key,u=s.signature.decode(e,"der"),l=u.s,h=u.r;c(l,a),c(h,a);var f=n.mont(i),p=l.invm(a),m=o.toRed(f).redPow(new n(t).mul(p).mod(a)).fromRed().mul(d.toRed(f).redPow(h.mul(p).mod(a)).fromRed()).mod(i).mod(a);return 0===m.cmp(h)}(e,t,l)}if("rsa"!==d&&"ecdsa/rsa"!==d)throw new Error("wrong public key type");t=i.concat([u,t]);for(var h=l.modulus.byteLength(),f=[1],p=0;t.length+f.length+2<h;)f.push(255),p+=1;f.push(0);for(var m=-1;++m<t.length;)f.push(t[m]);f=i.from(f);var b=n.mont(l.modulus);e=(e=new n(e).toRed(b)).redPow(new n(l.publicExponent)),e=i.from(e.fromRed().toArray());var g=p<8?1:0;for(h=Math.min(e.length,f.length),e.length!==f.length&&(g=1),m=-1;++m<h;)g|=e[m]^f[m];return 0===g}},{"./curves.json":87,"bn.js":60,elliptic:119,"parse-asn1":247,"safe-buffer":284}],91:[function(e,t,r){var i=Object.create||function(e){var t=function(){};return t.prototype=e,new t},n=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return r},a=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=i(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var o,c=10;try{var d={};Object.defineProperty&&Object.defineProperty(d,"x",{value:0}),o=0===d.x}catch(e){o=!1}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function l(e,t,r,n){var a,s,o;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]):(s=e._events=i(null),e._eventsCount=0),o){if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(a=u(e))&&a>0&&o.length>a){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",c.name,c.message)}}else o=s[t]=r,++e._eventsCount;return e}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function f(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=a.call(h,i);return n.listener=r,i.wrapFn=n,n}function p(e,t,r){var i=e._events;if(!i)return[];var n=i[t];return 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):b(n,n.length):[]}function m(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function b(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}o?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');c=e}}):s.defaultMaxListeners=c,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){var t,r,i,n,a,s,o="error"===e;if(s=this._events)o=o&&null==s.error;else if(!o)return!1;if(o){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var c=new Error('Unhandled "error" event. ('+t+")");throw c.context=t,c}if(!(r=s[e]))return!1;var d="function"==typeof r;switch(i=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var i=e.length,n=b(e,i),a=0;a<i;++a)n[a].call(r)}(r,d,this);break;case 2:!function(e,t,r,i){if(t)e.call(r,i);else for(var n=e.length,a=b(e,n),s=0;s<n;++s)a[s].call(r,i)}(r,d,this,arguments[1]);break;case 3:!function(e,t,r,i,n){if(t)e.call(r,i,n);else for(var a=e.length,s=b(e,a),o=0;o<a;++o)s[o].call(r,i,n)}(r,d,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,i,n,a){if(t)e.call(r,i,n,a);else for(var s=e.length,o=b(e,s),c=0;c<s;++c)o[c].call(r,i,n,a)}(r,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(n=new Array(i-1),a=1;a<i;a++)n[a-1]=arguments[a];!function(e,t,r,i){if(t)e.apply(r,i);else for(var n=e.length,a=b(e,n),s=0;s<n;++s)a[s].apply(r,i)}(r,d,this,n)}return!0},s.prototype.addListener=function(e,t){return l(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return l(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,f(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,f(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,n,a,s,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=i(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(a=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,a=s;break}if(a<0)return this;0===a?r.shift():function(e,t){for(var r=t,i=r+1,n=e.length;i<n;r+=1,i+=1)e[r]=e[i];e.pop()}(r,a),1===r.length&&(n[e]=r[0]),n.removeListener&&this.emit("removeListener",e,o||t)}return this},s.prototype.removeAllListeners=function(e){var t,r,a;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=i(null),this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=i(null):delete r[e]),this;if(0===arguments.length){var s,o=n(r);for(a=0;a<o.length;++a)"removeListener"!==(s=o[a])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=i(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)for(a=t.length-1;a>=0;a--)this.removeListener(e,t[a]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},s.prototype.listenerCount=m,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],92:[function(e,t,r){"use strict";var i=e("buffer").Buffer,n=e("buffer").SlowBuffer;function a(e,t){if(!i.isBuffer(e)||!i.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(var r=0,n=0;n<e.length;n++)r|=e[n]^t[n];return 0===r}t.exports=a,a.install=function(){i.prototype.equal=n.prototype.equal=function(e){return a(this,e)}};var s=i.prototype.equal,o=n.prototype.equal;a.restore=function(){i.prototype.equal=s,n.prototype.equal=o}},{buffer:94}],93:[function(e,t,r){(function(e){(function(){t.exports=function(t,r){for(var i=Math.min(t.length,r.length),n=new e(i),a=0;a<i;++a)n[a]=t[a]^r[a];return n}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:94}],94:[function(e,t,r){(function(t){(function(){
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).samvyo={})}(this,(function(e){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,s,i,a,n,o={},c={exports:{}};function d(){if(s)return r;s=1;var e=1e3,t=60*e,i=60*t,a=24*i,n=7*a,o=365.25*a;function c(e,t,r,s){var i=t>=1.5*r;return Math.round(e/r)+" "+s+(i?"s":"")}return r=function(r,s){s=s||{};var d=typeof r;if("string"===d&&r.length>0)return function(r){if((r=String(r)).length>100)return;var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!s)return;var c=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*n;case"days":case"day":case"d":return c*a;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*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(r);if("number"===d&&isFinite(r))return s.long?function(r){var s=Math.abs(r);if(s>=a)return c(r,s,a,"day");if(s>=i)return c(r,s,i,"hour");if(s>=t)return c(r,s,t,"minute");if(s>=e)return c(r,s,e,"second");return r+" ms"}(r):function(r){var s=Math.abs(r);if(s>=a)return Math.round(r/a)+"d";if(s>=i)return Math.round(r/i)+"h";if(s>=t)return Math.round(r/t)+"m";if(s>=e)return Math.round(r/e)+"s";return r+"ms"}(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))}}function p(){return n||(n=1,function(e,t){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 s=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(s++,"%c"===e&&(i=s))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(r){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(r){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.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)}})(),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=(a?i:(a=1,i=function(e){function t(e){let s,i,a,n=null;function o(...e){if(!o.enabled)return;const r=o,i=Number(new Date),a=i-(s||i);r.diff=a,r.prev=s,r.curr=i,s=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let n=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((s,i)=>{if("%%"===s)return"%";n++;const a=t.formatters[i];if("function"==typeof a){const t=e[n];s=a.call(r,t),e.splice(n,1),n--}return s})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=r,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==n?n:(i!==t.namespaces&&(i=t.namespaces,a=t.enabled(e)),a),set:e=>{n=e}}),"function"==typeof t.init&&t.init(o),o}function r(e,r){const s=t(this.namespace+(void 0===r?":":r)+e);return s.log=this.log,s}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(s),...t.skips.map(s).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 s=("string"==typeof e?e:"").split(/[\s,]+/),i=s.length;for(r=0;r<i;r++)s[r]&&("-"===(e=s[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,s;for(r=0,s=t.skips.length;r<s;r++)if(t.skips[r].test(e))return!1;for(r=0,s=t.names.length;r<s;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=d(),t.destroy=function(){},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}))(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}(c,c.exports)),c.exports}var l,h={},u={exports:{}},m=u.exports;function f(){return l||(l=1,e=u,t=u.exports,function(r,s){var i="function",a="undefined",n="object",o="string",c="major",d="model",p="name",l="type",h="vendor",u="version",m="architecture",f="console",g="mobile",b="tablet",_="smarttv",y="wearable",w="embedded",v="Amazon",S="Apple",R="ASUS",P="BlackBerry",C="Browser",k="Chrome",T="Firefox",D="Google",E="Huawei",I="LG",x="Microsoft",M="Motorola",O="Opera",L="Samsung",A="Sharp",j="Sony",N="Xiaomi",B="Zebra",F="Facebook",$="Chromium OS",U="Mac OS",q=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},V=function(e,t){return typeof e===o&&-1!==W(t).indexOf(W(e))},W=function(e){return e.toLowerCase()},K=function(e,t){if(typeof e===o)return e=e.replace(/^\s\s*/,""),typeof t===a?e:e.substring(0,500)},H=function(e,t){for(var r,a,o,c,d,p,l=0;l<t.length&&!d;){var h=t[l],u=t[l+1];for(r=a=0;r<h.length&&!d&&h[r];)if(d=h[r++].exec(e))for(o=0;o<u.length;o++)p=d[++a],typeof(c=u[o])===n&&c.length>0?2===c.length?typeof c[1]==i?this[c[0]]=c[1].call(this,p):this[c[0]]=c[1]:3===c.length?typeof c[1]!==i||c[1].exec&&c[1].test?this[c[0]]=p?p.replace(c[1],c[2]):s:this[c[0]]=p?c[1].call(this,p,c[2]):s:4===c.length&&(this[c[0]]=p?c[3].call(this,p.replace(c[1],c[2])):s):this[c]=p||s;l+=2}},G=function(e,t){for(var r in t)if(typeof t[r]===n&&t[r].length>0){for(var i=0;i<t[r].length;i++)if(V(t[r][i],e))return"?"===r?s:r}else if(V(t[r],e))return"?"===r?s:r;return e},z={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},J={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[u,[p,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[u,[p,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[p,u],[/opios[\/ ]+([\w\.]+)/i],[u,[p,O+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[u,[p,O+" GX"]],[/\bopr\/([\w\.]+)/i],[u,[p,O]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[u,[p,"Baidu"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim)\s?(?:browser)?[\/ ]?([\w\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[p,u],[/\bddg\/([\w\.]+)/i],[u,[p,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[u,[p,"UC"+C]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[u,[p,"WeChat"]],[/konqueror\/([\w\.]+)/i],[u,[p,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[u,[p,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[u,[p,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[u,[p,"Smart Lenovo "+C]],[/(avast|avg)\/([\w\.]+)/i],[[p,/(.+)/,"$1 Secure "+C],u],[/\bfocus\/([\w\.]+)/i],[u,[p,T+" Focus"]],[/\bopt\/([\w\.]+)/i],[u,[p,O+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[u,[p,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[u,[p,"Dolphin"]],[/coast\/([\w\.]+)/i],[u,[p,O+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[u,[p,"MIUI "+C]],[/fxios\/([-\w\.]+)/i],[u,[p,T]],[/\bqihu|(qi?ho?o?|360)browser/i],[[p,"360 "+C]],[/(oculus|sailfish|huawei|vivo)browser\/([\w\.]+)/i],[[p,/(.+)/,"$1 "+C],u],[/samsungbrowser\/([\w\.]+)/i],[u,[p,L+" Internet"]],[/(comodo_dragon)\/([\w\.]+)/i],[[p,/_/g," "],u],[/metasr[\/ ]?([\d\.]+)/i],[u,[p,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[p,"Sogou Mobile"],u],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345Explorer)[\/ ]?([\w\.]+)/i],[p,u],[/(lbbrowser)/i,/\[(linkedin)app\]/i],[p],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[p,F],u],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[p,u],[/\bgsa\/([\w\.]+) .*safari\//i],[u,[p,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[u,[p,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[u,[p,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[p,k+" WebView"],u],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[u,[p,"Android "+C]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[p,u],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[u,[p,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[u,p],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[p,[u,G,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[p,u],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[p,"Netscape"],u],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[u,[p,T+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[p,u],[/(cobalt)\/([\w\.]+)/i],[p,[u,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[m,"amd64"]],[/(ia32(?=;))/i],[[m,W]],[/((?:i[346]|x)86)[;\)]/i],[[m,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[m,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[m,"armhf"]],[/windows (ce|mobile); ppc;/i],[[m,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[m,/ower/,"",W]],[/(sun4\w)[;\)]/i],[[m,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[m,W]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[h,L],[l,b]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[d,[h,L],[l,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[h,S],[l,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[h,S],[l,b]],[/(macintosh);/i],[d,[h,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[h,A],[l,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[h,E],[l,b]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[h,E],[l,g]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[d,/_/g," "],[h,N],[l,g]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/g," "],[h,N],[l,b]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[d,[h,"OPPO"],[l,g]],[/\b(opd2\d{3}a?) bui/i],[d,[h,"OPPO"],[l,b]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[h,"Vivo"],[l,g]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[h,"Realme"],[l,g]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[d,[h,M],[l,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[h,M],[l,b]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[h,I],[l,b]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[d,[h,I],[l,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[h,"Lenovo"],[l,b]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g," "],[h,"Nokia"],[l,g]],[/(pixel c)\b/i],[d,[h,D],[l,b]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[h,D],[l,g]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[d,[h,j],[l,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,"Xperia Tablet"],[h,j],[l,b]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[h,"OnePlus"],[l,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[h,v],[l,b]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,"Fire Phone $1"],[h,v],[l,g]],[/(playbook);[-\w\),; ]+(rim)/i],[d,h,[l,b]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[h,P],[l,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[h,R],[l,b]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[h,R],[l,g]],[/(nexus 9)/i],[d,[h,"HTC"],[l,b]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[d,/_/g," "],[l,g]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[h,"Acer"],[l,b]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[h,"Meizu"],[l,g]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[h,"Ulefone"],[l,g]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,d,[l,g]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,d,[l,b]],[/(surface duo)/i],[d,[h,x],[l,b]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[h,"Fairphone"],[l,g]],[/(u304aa)/i],[d,[h,"AT&T"],[l,g]],[/\bsie-(\w*)/i],[d,[h,"Siemens"],[l,g]],[/\b(rct\w+) b/i],[d,[h,"RCA"],[l,b]],[/\b(venue[\d ]{2,7}) b/i],[d,[h,"Dell"],[l,b]],[/\b(q(?:mv|ta)\w+) b/i],[d,[h,"Verizon"],[l,b]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[h,"Barnes & Noble"],[l,b]],[/\b(tm\d{3}\w+) b/i],[d,[h,"NuVision"],[l,b]],[/\b(k88) b/i],[d,[h,"ZTE"],[l,b]],[/\b(nx\d{3}j) b/i],[d,[h,"ZTE"],[l,g]],[/\b(gen\d{3}) b.+49h/i],[d,[h,"Swiss"],[l,g]],[/\b(zur\d{3}) b/i],[d,[h,"Swiss"],[l,b]],[/\b((zeki)?tb.*\b) b/i],[d,[h,"Zeki"],[l,b]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],d,[l,b]],[/\b(ns-?\w{0,9}) b/i],[d,[h,"Insignia"],[l,b]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[h,"NextBook"],[l,b]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],d,[l,g]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],d,[l,g]],[/\b(ph-1) /i],[d,[h,"Essential"],[l,g]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[h,"Envizen"],[l,b]],[/\b(trio[-\w\. ]+) b/i],[d,[h,"MachSpeed"],[l,b]],[/\btu_(1491) b/i],[d,[h,"Rotor"],[l,b]],[/(shield[\w ]+) b/i],[d,[h,"Nvidia"],[l,b]],[/(sprint) (\w+)/i],[h,d,[l,g]],[/(kin\.[onetw]{3})/i],[[d,/\./g," "],[h,x],[l,g]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[h,B],[l,b]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[h,B],[l,g]],[/smart-tv.+(samsung)/i],[h,[l,_]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,"SmartTV"],[h,L],[l,_]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,I],[l,_]],[/(apple) ?tv/i],[h,[d,S+" TV"],[l,_]],[/crkey/i],[[d,k+"cast"],[h,D],[l,_]],[/droid.+aft(\w+)( bui|\))/i],[d,[h,v],[l,_]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[h,A],[l,_]],[/(bravia[\w ]+)( bui|\))/i],[d,[h,j],[l,_]],[/(mitv-\w{5}) bui/i],[d,[h,N],[l,_]],[/Hbbtv.*(technisat) (.*);/i],[h,d,[l,_]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,K],[d,K],[l,_]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[l,_]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,d,[l,f]],[/droid.+; (shield) bui/i],[d,[h,"Nvidia"],[l,f]],[/(playstation [345portablevi]+)/i],[d,[h,j],[l,f]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[h,x],[l,f]],[/((pebble))app/i],[h,d,[l,y]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[h,S],[l,y]],[/droid.+; (glass) \d/i],[d,[h,D],[l,y]],[/droid.+; (wt63?0{2,3})\)/i],[d,[h,B],[l,y]],[/(quest( \d| pro)?)/i],[d,[h,F],[l,y]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[l,w]],[/(aeobc)\b/i],[d,[h,v],[l,w]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[l,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[l,b]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[l,b]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[l,g]],[/(android[-\w\. ]{0,9});.+buil/i],[d,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[u,[p,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[u,[p,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[p,u],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[u,p]],os:[[/microsoft (windows) (vista|xp)/i],[p,u],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[p,[u,G,z]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[u,G,z],[p,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[u,/_/g,"."],[p,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[p,U],[u,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[u,p],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[p,u],[/\(bb(10);/i],[u,[p,P]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[u,[p,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[u,[p,T+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[u,[p,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[u,[p,"watchOS"]],[/crkey\/([\d\.]+)/i],[u,[p,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[p,$],u],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[p,u],[/(sunos) ?([\w\.\d]*)/i],[[p,"Solaris"],u],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[p,u]]},Q=function(e,t){if(typeof e===n&&(t=e,e=s),!(this instanceof Q))return new Q(e,t).getResult();var f=typeof r!==a&&r.navigator?r.navigator:s,_=e||(f&&f.userAgent?f.userAgent:""),y=f&&f.userAgentData?f.userAgentData:s,w=t?function(e,t){var r={};for(var s in e)t[s]&&t[s].length%2==0?r[s]=t[s].concat(e[s]):r[s]=e[s];return r}(J,t):J,v=f&&f.userAgent==_;return this.getBrowser=function(){var e,t={};return t[p]=s,t[u]=s,H.call(t,_,w.browser),t[c]=typeof(e=t[u])===o?e.replace(/[^\d\.]/g,"").split(".")[0]:s,v&&f&&f.brave&&typeof f.brave.isBrave==i&&(t[p]="Brave"),t},this.getCPU=function(){var e={};return e[m]=s,H.call(e,_,w.cpu),e},this.getDevice=function(){var e={};return e[h]=s,e[d]=s,e[l]=s,H.call(e,_,w.device),v&&!e[l]&&y&&y.mobile&&(e[l]=g),v&&"Macintosh"==e[d]&&f&&typeof f.standalone!==a&&f.maxTouchPoints&&f.maxTouchPoints>2&&(e[d]="iPad",e[l]=b),e},this.getEngine=function(){var e={};return e[p]=s,e[u]=s,H.call(e,_,w.engine),e},this.getOS=function(){var e={};return e[p]=s,e[u]=s,H.call(e,_,w.os),v&&!e[p]&&y&&y.platform&&"Unknown"!=y.platform&&(e[p]=y.platform.replace(/chrome os/i,$).replace(/macos/i,U)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return _},this.setUA=function(e){return _=typeof e===o&&e.length>500?K(e,500):e,this},this.setUA(_),this};Q.VERSION="1.0.38",Q.BROWSER=q([p,u,c]),Q.CPU=q([m]),Q.DEVICE=q([d,h,l,f,g,_,b,y,w]),Q.ENGINE=Q.OS=q([p,u]),e.exports&&(t=e.exports=Q),t.UAParser=Q;var X=typeof r!==a&&(r.jQuery||r.Zepto);if(X&&!X.ua){var Y=new Q;X.ua=Y.getResult(),X.ua.get=function(){return Y.getUA()},X.ua.set=function(e){Y.setUA(e);var t=Y.getResult();for(var r in t)X.ua[r]=t[r]}}}("object"==typeof window?window:m)),u.exports;var e,t}var g,b={};function _(){if(g)return b;g=1;var e=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(b,"__esModule",{value:!0}),b.Logger=void 0;const t=e(p()),r="mediasoup-client";return b.Logger=class{constructor(e){e?(this._debug=(0,t.default)(`${r}:${e}`),this._warn=(0,t.default)(`${r}:WARN:${e}`),this._error=(0,t.default)(`${r}:ERROR:${e}`)):(this._debug=(0,t.default)(r),this._warn=(0,t.default)(`${r}:WARN`),this._error=(0,t.default)(`${r}:ERROR`)),this._debug.log=void 0,this._warn.log=void 0,this._error.log=void 0}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}},b}var y,w,v={},S={exports:{}};function R(){if(y)return S.exports;y=1;var e,t="object"==typeof Reflect?Reflect:null,r=t&&"function"==typeof t.apply?t.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};e=t&&"function"==typeof t.ownKeys?t.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}S.exports=i,S.exports.once=function(e,t){return new Promise((function(r,s){function i(r){e.removeListener(t,a),s(r)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}m(e,t,a,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&m(e,"error",t,r)}(e,i,{once:!0})}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function n(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function o(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function c(e,t,r,s){var i,a,c;if(n(r),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),c=a[t]),void 0===c)c=a[t]=r,++e._eventsCount;else if("function"==typeof c?c=a[t]=s?[r,c]:[c,r]:s?c.unshift(r):c.push(r),(i=o(e))>0&&c.length>i&&!c.warned){c.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=c.length,console&&console.warn}return e}function d(){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 p(e,t,r){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=d.bind(s);return i.listener=r,s.wrapFn=i,i}function l(e,t,r){var s=e._events;if(void 0===s)return[];var i=s[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]: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}(i):u(i,i.length)}function h(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 u(e,t){for(var r=new Array(t),s=0;s<t;++s)r[s]=e[s];return r}function m(e,t,r,s){if("function"==typeof e.on)s.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 i(a){s.once&&e.removeEventListener(t,i),r(a)}))}}return Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),i.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},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(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},i.prototype.getMaxListeners=function(){return o(this)},i.prototype.emit=function(e){for(var t=[],s=1;s<arguments.length;s++)t.push(arguments[s]);var i="error"===e,a=this._events;if(void 0!==a)i=i&&void 0===a.error;else if(!i)return!1;if(i){var n;if(t.length>0&&(n=t[0]),n instanceof Error)throw n;var o=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw o.context=n,o}var c=a[e];if(void 0===c)return!1;if("function"==typeof c)r(c,this,t);else{var d=c.length,p=u(c,d);for(s=0;s<d;++s)r(p[s],this,t)}return!0},i.prototype.addListener=function(e,t){return c(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return c(this,e,t,!0)},i.prototype.once=function(e,t){return n(t),this.on(e,p(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return n(t),this.prependListener(e,p(this,e,t)),this},i.prototype.removeListener=function(e,t){var r,s,i,a,o;if(n(t),void 0===(s=this._events))return this;if(void 0===(r=s[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,a=r.length-1;a>=0;a--)if(r[a]===t||r[a].listener===t){o=r[a].listener,i=a;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(s[e]=r[0]),void 0!==s.removeListener&&this.emit("removeListener",e,o||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,r,s;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 i,a=Object.keys(r);for(s=0;s<a.length;++s)"removeListener"!==(i=a[s])&&this.removeAllListeners(i);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(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this},i.prototype.listeners=function(e){return l(this,e,!0)},i.prototype.rawListeners=function(e){return l(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},i.prototype.listenerCount=h,i.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]},S.exports}function P(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.EnhancedEventEmitter=void 0;const e=R(),t=new(_().Logger)("EnhancedEventEmitter");class r extends e.EventEmitter{constructor(){super(),this.setMaxListeners(1/0)}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...r){const s=super.listenerCount(e);try{return super.emit(e,...r)}catch(i){return t.error("safeEmit() | event listener threw an error [eventName:%s]:%o",e,i),Boolean(s)}}on(e,t){return super.on(e,t),this}off(e,t){return super.off(e,t),this}addListener(e,t){return super.on(e,t),this}prependListener(e,t){return super.prependListener(e,t),this}once(e,t){return super.once(e,t),this}prependOnceListener(e,t){return super.prependOnceListener(e,t),this}removeListener(e,t){return super.off(e,t),this}removeAllListeners(e){return super.removeAllListeners(e),this}listenerCount(e){return super.listenerCount(e)}listeners(e){return super.listeners(e)}rawListeners(e){return super.rawListeners(e)}}return v.EnhancedEventEmitter=r,v}var C,k={};function T(){if(C)return k;C=1,Object.defineProperty(k,"__esModule",{value:!0}),k.InvalidStateError=k.UnsupportedError=void 0;class e extends Error{constructor(t){super(t),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,e):this.stack=new Error(t).stack}}k.UnsupportedError=e;class t extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,t):this.stack=new Error(e).stack}}return k.InvalidStateError=t,k}var D,E={};function I(){if(D)return E;return D=1,Object.defineProperty(E,"__esModule",{value:!0}),E.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},E.generateRandomNumber=function(){return Math.round(1e7*Math.random())},E.deepFreeze=function e(t){const r=Reflect.ownKeys(t);for(const s of r){const r=t[s];(r&&"object"==typeof r||"function"==typeof r)&&e(r)}return Object.freeze(t)},E}var x,M,O,L={},A={},j={};function N(){if(M)return A;M=1,Object.defineProperty(A,"__esModule",{value:!0}),A.generateProfileLevelIdStringForAnswer=A.isSameProfile=A.parseSdpProfileLevelId=A.levelToString=A.profileToString=A.profileLevelIdToString=A.parseProfileLevelId=A.ProfileLevelId=A.Level=A.Profile=void 0;const e=new(function(){if(x)return j;x=1;var e=j&&j.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(j,"__esModule",{value:!0}),j.Logger=void 0;const t=e(p()),r="h264-profile-level-id";return j.Logger=class{constructor(e){e?(this._debug=(0,t.default)(`${r}:${e}`),this._warn=(0,t.default)(`${r}:WARN:${e}`),this._error=(0,t.default)(`${r}:ERROR:${e}`)):(this._debug=(0,t.default)(r),this._warn=(0,t.default)(`${r}:WARN`),this._error=(0,t.default)(`${r}:ERROR`)),this._debug.log=void 0,this._warn.log=void 0,this._error.log=void 0}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}},j}().Logger);var t,r,s,i;(r=t||(A.Profile=t={}))[r.ConstrainedBaseline=1]="ConstrainedBaseline",r[r.Baseline=2]="Baseline",r[r.Main=3]="Main",r[r.ConstrainedHigh=4]="ConstrainedHigh",r[r.High=5]="High",r[r.PredictiveHigh444=6]="PredictiveHigh444",(i=s||(A.Level=s={}))[i.L1_b=0]="L1_b",i[i.L1=10]="L1",i[i.L1_1=11]="L1_1",i[i.L1_2=12]="L1_2",i[i.L1_3=13]="L1_3",i[i.L2=20]="L2",i[i.L2_1=21]="L2_1",i[i.L2_2=22]="L2_2",i[i.L3=30]="L3",i[i.L3_1=31]="L3_1",i[i.L3_2=32]="L3_2",i[i.L4=40]="L4",i[i.L4_1=41]="L4_1",i[i.L4_2=42]="L4_2",i[i.L5=50]="L5",i[i.L5_1=51]="L5_1",i[i.L5_2=52]="L5_2";class a{constructor(e,t){this.profile=e,this.level=t}}A.ProfileLevelId=a;const n=new a(t.ConstrainedBaseline,s.L3_1);class o{constructor(e){this.mask=~m("x",e),this.masked_value=m("1",e)}isMatch(e){return this.masked_value===(e&this.mask)}}class c{constructor(e,t,r){this.profile_idc=e,this.profile_iop=t,this.profile=r}}const d=[new c(66,new o("x1xx0000"),t.ConstrainedBaseline),new c(77,new o("1xxx0000"),t.ConstrainedBaseline),new c(88,new o("11xx0000"),t.ConstrainedBaseline),new c(66,new o("x0xx0000"),t.Baseline),new c(88,new o("10xx0000"),t.Baseline),new c(77,new o("0x0x0000"),t.Main),new c(100,new o("00000000"),t.High),new c(100,new o("00001100"),t.ConstrainedHigh),new c(244,new o("00000000"),t.PredictiveHigh444)];function l(t){if("string"!=typeof t||6!==t.length)return;const r=parseInt(t,16);if(0===r)return;const i=255&r,n=r>>8&255,o=r>>16&255;let c;switch(i){case s.L1_1:c=16&n?s.L1_b:s.L1_1;break;case s.L1:case s.L1_2:case s.L1_3:case s.L2:case s.L2_1:case s.L2_2:case s.L3:case s.L3_1:case s.L3_2:case s.L4:case s.L4_1:case s.L4_2:case s.L5:case s.L5_1:case s.L5_2:c=i;break;default:return void e.warn(`parseProfileLevelId() | unrecognized level_idc [str:${t}, level_idc:${i}]`)}for(const e of d)if(o===e.profile_idc&&e.profile_iop.isMatch(n))return new a(e.profile,c);e.warn(`parseProfileLevelId() | unrecognized profile_idc/profile_iop combination [str:${t}, profile_idc:${o}, profile_iop:${n}]`)}function h(r){if(r.level==s.L1_b)switch(r.profile){case t.ConstrainedBaseline:return"42f00b";case t.Baseline:return"42100b";case t.Main:return"4d100b";default:return void e.warn(`profileLevelIdToString() | Level 1_b not is allowed for profile ${r.profile}`)}let i;switch(r.profile){case t.ConstrainedBaseline:i="42e0";break;case t.Baseline:i="4200";break;case t.Main:i="4d00";break;case t.ConstrainedHigh:i="640c";break;case t.High:i="6400";break;case t.PredictiveHigh444:i="f400";break;default:return void e.warn(`profileLevelIdToString() | unrecognized profile ${r.profile}`)}let a=r.level.toString(16);return 1===a.length&&(a=`0${a}`),`${i}${a}`}function u(e={}){const t=e["profile-level-id"];return t?l(t):n}function m(e,t){return Number(t[0]===e)<<7|Number(t[1]===e)<<6|Number(t[2]===e)<<5|Number(t[3]===e)<<4|Number(t[4]===e)<<3|Number(t[5]===e)<<2|Number(t[6]===e)<<1|Number(t[7]===e)}function f(e={}){const t=e["level-asymmetry-allowed"];return!0===t||1===t||"1"===t}return A.parseProfileLevelId=l,A.profileLevelIdToString=h,A.profileToString=function(r){switch(r){case t.ConstrainedBaseline:return"ConstrainedBaseline";case t.Baseline:return"Baseline";case t.Main:return"Main";case t.ConstrainedHigh:return"ConstrainedHigh";case t.High:return"High";case t.PredictiveHigh444:return"PredictiveHigh444";default:return void e.warn(`profileToString() | unrecognized profile ${r}`)}},A.levelToString=function(t){switch(t){case s.L1_b:return"1b";case s.L1:return"1";case s.L1_1:return"1.1";case s.L1_2:return"1.2";case s.L1_3:return"1.3";case s.L2:return"2";case s.L2_1:return"2.1";case s.L2_2:return"2.2";case s.L3:return"3";case s.L3_1:return"3.1";case s.L3_2:return"3.2";case s.L4:return"4";case s.L4_1:return"4.1";case s.L4_2:return"4.2";case s.L5:return"5";case s.L5_1:return"5.1";case s.L5_2:return"5.2";default:return void e.warn(`levelToString() | unrecognized level ${t}`)}},A.parseSdpProfileLevelId=u,A.isSameProfile=function(e={},t={}){const r=u(e),s=u(t);return Boolean(r&&s&&r.profile===s.profile)},A.generateProfileLevelIdStringForAnswer=function(t={},r={}){if(!t["profile-level-id"]&&!r["profile-level-id"])return void e.warn("generateProfileLevelIdStringForAnswer() | profile-level-id missing in local and remote params");const i=u(t),n=u(r);if(!i)throw new TypeError("invalid local_profile_level_id");if(!n)throw new TypeError("invalid remote_profile_level_id");if(i.profile!==n.profile)throw new TypeError("H264 Profile mismatch");const o=f(t)&&f(r),c=i.level,d=n.level,p=function(e,t){return e===s.L1_b?t!==s.L1&&t!==s.L1_b:t===s.L1_b?e!==s.L1:e<t}(l=c,m=d)?l:m;var l,m;const g=o?c:p;return e.debug(`generateProfileLevelIdStringForAnswer() | result [profile:${i.profile}, level:${g}]`),h(new a(i.profile,g))},A}function B(){if(O)return L;O=1;var e=L&&L.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=L&&L.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=L&&L.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(L,"__esModule",{value:!0}),L.validateRtpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(e.codecs&&!Array.isArray(e.codecs))throw new TypeError("caps.codecs is not an array");e.codecs||(e.codecs=[]);for(const t of e.codecs)d(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("caps.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)l(t)},L.validateRtpParameters=c,L.validateSctpStreamParameters=function(e){if("object"!=typeof e)throw new TypeError("params is not an object");if("number"!=typeof e.streamId)throw new TypeError("missing params.streamId");let t=!1;"boolean"==typeof e.ordered?t=!0:e.ordered=!0;if(e.maxPacketLifeTime&&"number"!=typeof e.maxPacketLifeTime)throw new TypeError("invalid params.maxPacketLifeTime");if(e.maxRetransmits&&"number"!=typeof e.maxRetransmits)throw new TypeError("invalid params.maxRetransmits");if(e.maxPacketLifeTime&&e.maxRetransmits)throw new TypeError("cannot provide both maxPacketLifeTime and maxRetransmits");if(t&&e.ordered&&(e.maxPacketLifeTime||e.maxRetransmits))throw new TypeError("cannot be ordered with maxPacketLifeTime or maxRetransmits");t||!e.maxPacketLifeTime&&!e.maxRetransmits||(e.ordered=!1);if(e.label&&"string"!=typeof e.label)throw new TypeError("invalid params.label");if(e.protocol&&"string"!=typeof e.protocol)throw new TypeError("invalid params.protocol")},L.validateSctpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(!e.numStreams||"object"!=typeof e.numStreams)throw new TypeError("missing caps.numStreams");!function(e){if("object"!=typeof e)throw new TypeError("numStreams is not an object");if("number"!=typeof e.OS)throw new TypeError("missing numStreams.OS");if("number"!=typeof e.MIS)throw new TypeError("missing numStreams.MIS")}(e.numStreams)},L.getExtendedRtpCapabilities=function(e,t){const r={codecs:[],headerExtensions:[]};for(const s of t.codecs||[]){if(f(s))continue;const t=(e.codecs||[]).find((e=>g(e,s,{strict:!0,modify:!0})));if(!t)continue;const i={mimeType:t.mimeType,kind:t.kind,clockRate:t.clockRate,channels:t.channels,localPayloadType:t.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:s.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:t.parameters,remoteParameters:s.parameters,rtcpFeedback:_(t,s)};r.codecs.push(i)}for(const s of r.codecs){const r=e.codecs.find((e=>f(e)&&e.parameters.apt===s.localPayloadType)),i=t.codecs.find((e=>f(e)&&e.parameters.apt===s.remotePayloadType));r&&i&&(s.localRtxPayloadType=r.preferredPayloadType,s.remoteRtxPayloadType=i.preferredPayloadType)}for(const s of t.headerExtensions){const t=e.headerExtensions.find((e=>b(e,s)));if(!t)continue;const i={kind:s.kind,uri:s.uri,sendId:t.preferredId,recvId:s.preferredId,encrypt:t.preferredEncrypt,direction:"sendrecv"};switch(s.direction){case"sendrecv":i.direction="sendrecv";break;case"recvonly":i.direction="sendonly";break;case"sendonly":i.direction="recvonly";break;case"inactive":i.direction="inactive"}r.headerExtensions.push(i)}return r},L.getRecvRtpCapabilities=function(e){const t={codecs:[],headerExtensions:[]};for(const r of e.codecs){const e={mimeType:r.mimeType,kind:r.kind,preferredPayloadType:r.remotePayloadType,clockRate:r.clockRate,channels:r.channels,parameters:r.localParameters,rtcpFeedback:r.rtcpFeedback};if(t.codecs.push(e),!r.remoteRtxPayloadType)continue;const s={mimeType:`${r.kind}/rtx`,kind:r.kind,preferredPayloadType:r.remoteRtxPayloadType,clockRate:r.clockRate,parameters:{apt:r.remotePayloadType},rtcpFeedback:[]};t.codecs.push(s)}for(const r of e.headerExtensions){if("sendrecv"!==r.direction&&"recvonly"!==r.direction)continue;const e={kind:r.kind,uri:r.uri,preferredId:r.recvId,preferredEncrypt:r.encrypt,direction:r.direction};t.headerExtensions.push(e)}return t},L.getSendingRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const s of t.codecs){if(s.kind!==e)continue;const t={mimeType:s.mimeType,payloadType:s.localPayloadType,clockRate:s.clockRate,channels:s.channels,parameters:s.localParameters,rtcpFeedback:s.rtcpFeedback};if(r.codecs.push(t),s.localRtxPayloadType){const e={mimeType:`${s.kind}/rtx`,payloadType:s.localRtxPayloadType,clockRate:s.clockRate,parameters:{apt:s.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const s of t.headerExtensions){if(s.kind&&s.kind!==e||"sendrecv"!==s.direction&&"sendonly"!==s.direction)continue;const t={uri:s.uri,id:s.sendId,encrypt:s.encrypt,parameters:{}};r.headerExtensions.push(t)}return r},L.getSendingRemoteRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const s of t.codecs){if(s.kind!==e)continue;const t={mimeType:s.mimeType,payloadType:s.localPayloadType,clockRate:s.clockRate,channels:s.channels,parameters:s.remoteParameters,rtcpFeedback:s.rtcpFeedback};if(r.codecs.push(t),s.localRtxPayloadType){const e={mimeType:`${s.kind}/rtx`,payloadType:s.localRtxPayloadType,clockRate:s.clockRate,parameters:{apt:s.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const s of t.headerExtensions){if(s.kind&&s.kind!==e||"sendrecv"!==s.direction&&"sendonly"!==s.direction)continue;const t={uri:s.uri,id:s.sendId,encrypt:s.encrypt,parameters:{}};r.headerExtensions.push(t)}if(r.headerExtensions.some((e=>"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"===e.uri)))for(const s of r.codecs)s.rtcpFeedback=(s.rtcpFeedback||[]).filter((e=>"goog-remb"!==e.type));else if(r.headerExtensions.some((e=>"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"===e.uri)))for(const s of r.codecs)s.rtcpFeedback=(s.rtcpFeedback||[]).filter((e=>"transport-cc"!==e.type));else for(const s of r.codecs)s.rtcpFeedback=(s.rtcpFeedback||[]).filter((e=>"transport-cc"!==e.type&&"goog-remb"!==e.type));return r},L.reduceCodecs=function(e,t){const r=[];if(t){for(let s=0;s<e.length;++s)if(g(e[s],t,{strict:!0})){r.push(e[s]),f(e[s+1])&&r.push(e[s+1]);break}if(0===r.length)throw new TypeError("no matching codec found")}else r.push(e[0]),f(e[1])&&r.push(e[1]);return r},L.generateProbatorRtpParameters=function(e){c(e=i.clone(e));const t={mid:a,codecs:[],headerExtensions:[],encodings:[{ssrc:n}],rtcp:{cname:"probator"}};return t.codecs.push(e.codecs[0]),t.codecs[0].payloadType=o,t.headerExtensions=e.headerExtensions,t},L.canSend=function(e,t){return t.codecs.some((t=>t.kind===e))},L.canReceive=function(e,t){if(c(e),0===e.codecs.length)return!1;const r=e.codecs[0];return t.codecs.some((e=>e.remotePayloadType===r.payloadType))};const s=r(N()),i=r(I()),a="probator",n=1234,o=127;function c(e){if("object"!=typeof e)throw new TypeError("params is not an object");if(e.mid&&"string"!=typeof e.mid)throw new TypeError("params.mid is not a string");if(!Array.isArray(e.codecs))throw new TypeError("missing params.codecs");for(const t of e.codecs)h(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("params.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)u(t);if(e.encodings&&!Array.isArray(e.encodings))throw new TypeError("params.encodings is not an array");e.encodings||(e.encodings=[]);for(const t of e.encodings)m(t);if(e.rtcp&&"object"!=typeof e.rtcp)throw new TypeError("params.rtcp is not an object");e.rtcp||(e.rtcp={}),function(e){if("object"!=typeof e)throw new TypeError("rtcp is not an object");if(e.cname&&"string"!=typeof e.cname)throw new TypeError("invalid rtcp.cname");e.reducedSize&&"boolean"==typeof e.reducedSize||(e.reducedSize=!0)}(e.rtcp)}function d(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if(e.kind=r[1].toLowerCase(),e.preferredPayloadType&&"number"!=typeof e.preferredPayloadType)throw new TypeError("invalid codec.preferredPayloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===e.kind?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const s of Object.keys(e.parameters)){let t=e.parameters[s];if(void 0===t&&(e.parameters[s]="",t=""),"string"!=typeof t&&"number"!=typeof t)throw new TypeError(`invalid codec parameter [key:${s}s, value:${t}]`);if("apt"===s&&"number"!=typeof t)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const s of e.rtcpFeedback)p(s)}function p(e){if("object"!=typeof e)throw new TypeError("fb is not an object");if(!e.type||"string"!=typeof e.type)throw new TypeError("missing fb.type");e.parameter&&"string"==typeof e.parameter||(e.parameter="")}function l(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if("audio"!==e.kind&&"video"!==e.kind)throw new TypeError("invalid ext.kind");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.preferredId)throw new TypeError("missing ext.preferredId");if(e.preferredEncrypt&&"boolean"!=typeof e.preferredEncrypt)throw new TypeError("invalid ext.preferredEncrypt");if(e.preferredEncrypt||(e.preferredEncrypt=!1),e.direction&&"string"!=typeof e.direction)throw new TypeError("invalid ext.direction");e.direction||(e.direction="sendrecv")}function h(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if("number"!=typeof e.payloadType)throw new TypeError("missing codec.payloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===r[1].toLowerCase()?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const s of Object.keys(e.parameters)){let t=e.parameters[s];if(void 0===t&&(e.parameters[s]="",t=""),"string"!=typeof t&&"number"!=typeof t)throw new TypeError(`invalid codec parameter [key:${s}s, value:${t}]`);if("apt"===s&&"number"!=typeof t)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const s of e.rtcpFeedback)p(s)}function u(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.id)throw new TypeError("missing ext.id");if(e.encrypt&&"boolean"!=typeof e.encrypt)throw new TypeError("invalid ext.encrypt");e.encrypt||(e.encrypt=!1),e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError("invalid header extension parameter")}}function m(e){if("object"!=typeof e)throw new TypeError("encoding is not an object");if(e.ssrc&&"number"!=typeof e.ssrc)throw new TypeError("invalid encoding.ssrc");if(e.rid&&"string"!=typeof e.rid)throw new TypeError("invalid encoding.rid");if(e.rtx&&"object"!=typeof e.rtx)throw new TypeError("invalid encoding.rtx");if(e.rtx&&"number"!=typeof e.rtx.ssrc)throw new TypeError("missing encoding.rtx.ssrc");if(e.dtx&&"boolean"==typeof e.dtx||(e.dtx=!1),e.scalabilityMode&&"string"!=typeof e.scalabilityMode)throw new TypeError("invalid encoding.scalabilityMode")}function f(e){return!!e&&/.+\/rtx$/i.test(e.mimeType)}function g(e,t,{strict:r=!1,modify:i=!1}={}){const a=e.mimeType.toLowerCase();if(a!==t.mimeType.toLowerCase())return!1;if(e.clockRate!==t.clockRate)return!1;if(e.channels!==t.channels)return!1;switch(a){case"video/h264":if(r){if((e.parameters["packetization-mode"]||0)!==(t.parameters["packetization-mode"]||0))return!1;if(!s.isSameProfile(e.parameters,t.parameters))return!1;let r;try{r=s.generateProfileLevelIdStringForAnswer(e.parameters,t.parameters)}catch(n){return!1}i&&(r?(e.parameters["profile-level-id"]=r,t.parameters["profile-level-id"]=r):(delete e.parameters["profile-level-id"],delete t.parameters["profile-level-id"]))}break;case"video/vp9":if(r){if((e.parameters["profile-id"]||0)!==(t.parameters["profile-id"]||0))return!1}}return!0}function b(e,t){return(!e.kind||!t.kind||e.kind===t.kind)&&e.uri===t.uri}function _(e,t){const r=[];for(const s of e.rtcpFeedback||[]){const e=(t.rtcpFeedback||[]).find((e=>e.type===s.type&&(e.parameter===s.parameter||!e.parameter&&!s.parameter)));e&&r.push(e)}return r}return L}var F,$,U,q,V={},W={},K={};function H(){if($)return W;$=1,Object.defineProperty(W,"__esModule",{value:!0}),W.AwaitQueue=W.AwaitQueueRemovedTaskError=W.AwaitQueueStoppedError=void 0;const e=new(function(){if(F)return K;F=1,Object.defineProperty(K,"__esModule",{value:!0}),K.Logger=void 0;const e=p(),t="awaitqueue";return K.Logger=class{constructor(r){r?(this._debug=(0,e.default)(`${t}:${r}`),this._warn=(0,e.default)(`${t}:WARN:${r}`),this._error=(0,e.default)(`${t}:ERROR:${r}`)):(this._debug=(0,e.default)(t),this._warn=(0,e.default)(`${t}:WARN`),this._error=(0,e.default)(`${t}:ERROR`)),this._debug.log=void 0,this._warn.log=void 0,this._error.log=void 0}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}},K}().Logger);class t extends Error{constructor(e){super(e??"AwaitQueue stopped"),this.name="AwaitQueueStoppedError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}}W.AwaitQueueStoppedError=t;class r extends Error{constructor(e){super(e??"AwaitQueue task removed"),this.name="AwaitQueueRemovedTaskError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,r)}}W.AwaitQueueRemovedTaskError=r;return W.AwaitQueue=class{constructor(){this.pendingTasks=new Map,this.nextTaskId=0,this.stopping=!1}get size(){return this.pendingTasks.size}async push(t,r){if(r=r??t.name,e.debug(`push() [name:${r}]`),"function"!=typeof t)throw new TypeError("given task is not a function");if(r)try{Object.defineProperty(t,"name",{value:r})}catch(s){}return new Promise(((s,i)=>{const a={id:this.nextTaskId++,task:t,name:r,enqueuedAt:Date.now(),executedAt:void 0,completed:!1,resolve:t=>{if(a.completed)return;a.completed=!0,this.pendingTasks.delete(a.id),e.debug(`resolving task [name:${a.name}]`),s(t);const[r]=this.pendingTasks.values();r&&!r.executedAt&&this.execute(r)},reject:t=>{if(!a.completed&&(a.completed=!0,this.pendingTasks.delete(a.id),e.debug(`rejecting task [name:${a.name}]: %s`,String(t)),i(t),!this.stopping)){const[e]=this.pendingTasks.values();e&&!e.executedAt&&this.execute(e)}}};this.pendingTasks.set(a.id,a),1===this.pendingTasks.size&&this.execute(a)}))}stop(){e.debug("stop()"),this.stopping=!0;for(const r of this.pendingTasks.values())e.debug(`stop() | stopping task [name:${r.name}]`),r.reject(new t);this.stopping=!1}remove(t){e.debug(`remove() [taskIdx:${t}]`);const s=Array.from(this.pendingTasks.values())[t];s?s.reject(new r):e.debug(`stop() | no task with given idx [taskIdx:${t}]`)}dump(){const e=Date.now();let t=0;return Array.from(this.pendingTasks.values()).map((r=>({idx:t++,task:r.task,name:r.name,enqueuedTime:r.executedAt?r.executedAt-r.enqueuedAt:e-r.enqueuedAt,executionTime:r.executedAt?e-r.executedAt:0})))}async execute(t){if(e.debug(`execute() [name:${t.name}]`),t.executedAt)throw new Error("task already being executed");t.executedAt=Date.now();try{const e=await t.task();t.resolve(e)}catch(r){t.reject(r)}}},W}
|
|
2
|
+
/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var G,z={};function J(){if(G)return z;G=1,Object.defineProperty(z,"__esModule",{value:!0}),z.Producer=void 0;const e=_(),t=P(),r=T(),s=new e.Logger("Producer");let i=class extends t.EnhancedEventEmitter{constructor({id:e,localId:r,rtpSender:i,track:a,rtpParameters:n,stopTracks:o,disableTrackOnPause:c,zeroRtpOnPause:d,appData:p}){super(),this._closed=!1,this._observer=new t.EnhancedEventEmitter,s.debug("constructor()"),this._id=e,this._localId=r,this._rtpSender=i,this._track=a,this._kind=a.kind,this._rtpParameters=n,this._paused=!!c&&!a.enabled,this._maxSpatialLayer=void 0,this._stopTracks=o,this._disableTrackOnPause=c,this._zeroRtpOnPause=d,this._appData=p||{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get closed(){return this._closed}get kind(){return this._kind}get rtpSender(){return this._rtpSender}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get maxSpatialLayer(){return this._maxSpatialLayer}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(s.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(s.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new r.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){s.debug("pause()"),this._closed?s.error("pause() | Producer closed"):(this._paused=!0,this._track&&this._disableTrackOnPause&&(this._track.enabled=!1),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@pause",e,t)})).catch((()=>{})),this._observer.safeEmit("pause"))}resume(){s.debug("resume()"),this._closed?s.error("resume() | Producer closed"):(this._paused=!1,this._track&&this._disableTrackOnPause&&(this._track.enabled=!0),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@resume",e,t)})).catch((()=>{})),this._observer.safeEmit("resume"))}async replaceTrack({track:e}){if(s.debug("replaceTrack() [track:%o]",e),this._closed){if(e&&this._stopTracks)try{e.stop()}catch(t){}throw new r.InvalidStateError("closed")}if(e&&"ended"===e.readyState)throw new r.InvalidStateError("track ended");e!==this._track?(await new Promise(((t,r)=>{this.safeEmit("@replacetrack",e,t,r)})),this.destroyTrack(),this._track=e,this._track&&this._disableTrackOnPause&&(this._paused?this._paused&&(this._track.enabled=!1):this._track.enabled=!0),this.handleTrack()):s.debug("replaceTrack() | same track, ignored")}async setMaxSpatialLayer(e){if(this._closed)throw new r.InvalidStateError("closed");if("video"!==this._kind)throw new r.UnsupportedError("not a video Producer");if("number"!=typeof e)throw new TypeError("invalid spatialLayer");e!==this._maxSpatialLayer&&(await new Promise(((t,r)=>{this.safeEmit("@setmaxspatiallayer",e,t,r)})).catch((()=>{})),this._maxSpatialLayer=e)}async setRtpEncodingParameters(e){if(this._closed)throw new r.InvalidStateError("closed");if("object"!=typeof e)throw new TypeError("invalid params");await new Promise(((t,r)=>{this.safeEmit("@setrtpencodingparameters",e,t,r)}))}onTrackEnded(){s.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track&&this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){if(this._track)try{this._track.removeEventListener("ended",this.onTrackEnded),this._stopTracks&&this._track.stop()}catch(e){}}};return z.Producer=i,z}var Q,X={};function Y(){if(Q)return X;Q=1,Object.defineProperty(X,"__esModule",{value:!0}),X.Consumer=void 0;const e=_(),t=P(),r=T(),s=new e.Logger("Consumer");let i=class extends t.EnhancedEventEmitter{constructor({id:e,localId:r,producerId:i,rtpReceiver:a,track:n,rtpParameters:o,appData:c}){super(),this._closed=!1,this._observer=new t.EnhancedEventEmitter,s.debug("constructor()"),this._id=e,this._localId=r,this._producerId=i,this._rtpReceiver=a,this._track=n,this._rtpParameters=o,this._paused=!n.enabled,this._appData=c||{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get producerId(){return this._producerId}get closed(){return this._closed}get kind(){return this._track.kind}get rtpReceiver(){return this._rtpReceiver}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(s.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(s.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new r.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){s.debug("pause()"),this._closed?s.error("pause() | Consumer closed"):this._paused?s.debug("pause() | Consumer is already paused"):(this._paused=!0,this._track.enabled=!1,this.emit("@pause"),this._observer.safeEmit("pause"))}resume(){s.debug("resume()"),this._closed?s.error("resume() | Consumer closed"):this._paused?(this._paused=!1,this._track.enabled=!0,this.emit("@resume"),this._observer.safeEmit("resume")):s.debug("resume() | Consumer is already resumed")}onTrackEnded(){s.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){try{this._track.removeEventListener("ended",this.onTrackEnded),this._track.stop()}catch(e){}}};return X.Consumer=i,X}var Z,ee={};function te(){if(Z)return ee;Z=1,Object.defineProperty(ee,"__esModule",{value:!0}),ee.DataProducer=void 0;const e=_(),t=P(),r=T(),s=new e.Logger("DataProducer");let i=class extends t.EnhancedEventEmitter{constructor({id:e,dataChannel:r,sctpStreamParameters:i,appData:a}){super(),this._closed=!1,this._observer=new t.EnhancedEventEmitter,s.debug("constructor()"),this._id=e,this._dataChannel=r,this._sctpStreamParameters=i,this._appData=a||{},this.handleDataChannel()}get id(){return this._id}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get bufferedAmount(){return this._dataChannel.bufferedAmount}get bufferedAmountLowThreshold(){return this._dataChannel.bufferedAmountLowThreshold}set bufferedAmountLowThreshold(e){this._dataChannel.bufferedAmountLowThreshold=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(s.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(s.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}send(e){if(s.debug("send()"),this._closed)throw new r.InvalidStateError("closed");this._dataChannel.send(e)}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(s.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;let{error:t}=e;t||(t=new Error("unknown DataChannel error")),"sctp-failure"===t.errorDetail?s.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):s.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(s.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(()=>{this._closed||s.warn('DataChannel "message" event in a DataProducer, message discarded')})),this._dataChannel.addEventListener("bufferedamountlow",(()=>{this._closed||this.safeEmit("bufferedamountlow")}))}};return ee.DataProducer=i,ee}var re,se,ie={};function ae(){if(re)return ie;re=1,Object.defineProperty(ie,"__esModule",{value:!0}),ie.DataConsumer=void 0;const e=_(),t=P(),r=new e.Logger("DataConsumer");let s=class extends t.EnhancedEventEmitter{constructor({id:e,dataProducerId:s,dataChannel:i,sctpStreamParameters:a,appData:n}){super(),this._closed=!1,this._observer=new t.EnhancedEventEmitter,r.debug("constructor()"),this._id=e,this._dataProducerId=s,this._dataChannel=i,this._sctpStreamParameters=a,this._appData=n||{},this.handleDataChannel()}get id(){return this._id}get dataProducerId(){return this._dataProducerId}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get binaryType(){return this._dataChannel.binaryType}set binaryType(e){this._dataChannel.binaryType=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(r.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(r.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(r.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;let{error:t}=e;t||(t=new Error("unknown DataChannel error")),"sctp-failure"===t.errorDetail?r.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):r.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(r.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(e=>{this._closed||this.safeEmit("message",e.data)}))}};return ie.DataConsumer=s,ie}function ne(){if(se)return V;se=1;var e=V&&V.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=V&&V.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=V&&V.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s},s=V&&V.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(V,"__esModule",{value:!0}),V.Transport=void 0;const i=H(),a=s(function(){if(q)return U;let e;return q=1,U="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:globalThis):t=>(e||(e=Promise.resolve())).then(t).catch((e=>setTimeout((()=>{throw e}),0)))}()),n=_(),o=P(),c=T(),d=r(I()),p=r(B()),l=J(),h=Y(),u=te(),m=ae(),f=new n.Logger("Transport");class g{constructor(e){this.consumerOptions=e,this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class b extends o.EnhancedEventEmitter{constructor({direction:e,id:t,iceParameters:r,iceCandidates:s,dtlsParameters:a,sctpParameters:n,iceServers:c,iceTransportPolicy:p,additionalSettings:l,proprietaryConstraints:h,appData:u,handlerFactory:m,extendedRtpCapabilities:g,canProduceByKind:b}){super(),this._closed=!1,this._iceGatheringState="new",this._connectionState="new",this._producers=new Map,this._consumers=new Map,this._dataProducers=new Map,this._dataConsumers=new Map,this._probatorConsumerCreated=!1,this._awaitQueue=new i.AwaitQueue,this._pendingConsumerTasks=[],this._consumerCreationInProgress=!1,this._pendingPauseConsumers=new Map,this._consumerPauseInProgress=!1,this._pendingResumeConsumers=new Map,this._consumerResumeInProgress=!1,this._pendingCloseConsumers=new Map,this._consumerCloseInProgress=!1,this._observer=new o.EnhancedEventEmitter,f.debug("constructor() [id:%s, direction:%s]",t,e),this._id=t,this._direction=e,this._extendedRtpCapabilities=g,this._canProduceByKind=b,this._maxSctpMessageSize=n?n.maxMessageSize:null;const _=d.clone(l)||{};delete _.iceServers,delete _.iceTransportPolicy,delete _.bundlePolicy,delete _.rtcpMuxPolicy,delete _.sdpSemantics,this._handler=m(),this._handler.run({direction:e,iceParameters:r,iceCandidates:s,dtlsParameters:a,sctpParameters:n,iceServers:c,iceTransportPolicy:p,additionalSettings:_,proprietaryConstraints:h,extendedRtpCapabilities:g}),this._appData=u||{},this.handleHandler()}get id(){return this._id}get closed(){return this._closed}get direction(){return this._direction}get handler(){return this._handler}get iceGatheringState(){return this._iceGatheringState}get connectionState(){return this._connectionState}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){if(!this._closed){f.debug("close()"),this._closed=!0,this._awaitQueue.stop(),this._handler.close(),this._connectionState="closed";for(const e of this._producers.values())e.transportClosed();this._producers.clear();for(const e of this._consumers.values())e.transportClosed();this._consumers.clear();for(const e of this._dataProducers.values())e.transportClosed();this._dataProducers.clear();for(const e of this._dataConsumers.values())e.transportClosed();this._dataConsumers.clear(),this._observer.safeEmit("close")}}async getStats(){if(this._closed)throw new c.InvalidStateError("closed");return this._handler.getTransportStats()}async restartIce({iceParameters:e}){if(f.debug("restartIce()"),this._closed)throw new c.InvalidStateError("closed");if(!e)throw new TypeError("missing iceParameters");return this._awaitQueue.push((async()=>await this._handler.restartIce(e)),"transport.restartIce()")}async updateIceServers({iceServers:e}={}){if(f.debug("updateIceServers()"),this._closed)throw new c.InvalidStateError("closed");if(!Array.isArray(e))throw new TypeError("missing iceServers");return this._awaitQueue.push((async()=>this._handler.updateIceServers(e)),"transport.updateIceServers()")}async produce({track:e,encodings:t,codecOptions:r,codec:s,stopTracks:i=!0,disableTrackOnPause:a=!0,zeroRtpOnPause:n=!1,onRtpSender:o,appData:d={}}={}){if(f.debug("produce() [track:%o]",e),this._closed)throw new c.InvalidStateError("closed");if(!e)throw new TypeError("missing track");if("send"!==this._direction)throw new c.UnsupportedError("not a sending Transport");if(!this._canProduceByKind[e.kind])throw new c.UnsupportedError(`cannot produce ${e.kind}`);if("ended"===e.readyState)throw new c.InvalidStateError("track ended");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("produce"))throw new TypeError('no "produce" listener set into this transport');if(d&&"object"!=typeof d)throw new TypeError("if given, appData must be an object");return this._awaitQueue.push((async()=>{let c;if(t&&!Array.isArray(t))throw TypeError("encodings must be an array");t&&0===t.length?c=void 0:t&&(c=t.map((e=>{const t={active:!0};return!1===e.active&&(t.active=!1),"boolean"==typeof e.dtx&&(t.dtx=e.dtx),"string"==typeof e.scalabilityMode&&(t.scalabilityMode=e.scalabilityMode),"number"==typeof e.scaleResolutionDownBy&&(t.scaleResolutionDownBy=e.scaleResolutionDownBy),"number"==typeof e.maxBitrate&&(t.maxBitrate=e.maxBitrate),"number"==typeof e.maxFramerate&&(t.maxFramerate=e.maxFramerate),"boolean"==typeof e.adaptivePtime&&(t.adaptivePtime=e.adaptivePtime),"string"==typeof e.priority&&(t.priority=e.priority),"string"==typeof e.networkPriority&&(t.networkPriority=e.networkPriority),t})));const{localId:h,rtpParameters:u,rtpSender:m}=await this._handler.send({track:e,encodings:c,codecOptions:r,codec:s,onRtpSender:o});try{p.validateRtpParameters(u);const{id:t}=await new Promise(((t,r)=>{this.safeEmit("produce",{kind:e.kind,rtpParameters:u,appData:d},t,r)})),r=new l.Producer({id:t,localId:h,rtpSender:m,track:e,rtpParameters:u,stopTracks:i,disableTrackOnPause:a,zeroRtpOnPause:n,appData:d});return this._producers.set(r.id,r),this.handleProducer(r),this._observer.safeEmit("newproducer",r),r}catch(f){throw this._handler.stopSending(h).catch((()=>{})),f}}),"transport.produce()").catch((t=>{if(i)try{e.stop()}catch(r){}throw t}))}async consume({id:e,producerId:t,kind:r,rtpParameters:s,streamId:i,onRtpReceiver:n,appData:o={}}){if(f.debug("consume()"),this._closed)throw new c.InvalidStateError("closed");if("recv"!==this._direction)throw new c.UnsupportedError("not a receiving Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing producerId");if("audio"!==r&&"video"!==r)throw new TypeError(`invalid kind '${r}'`);if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(o&&"object"!=typeof o)throw new TypeError("if given, appData must be an object");const l=d.clone(s);if(!p.canReceive(l,this._extendedRtpCapabilities))throw new c.UnsupportedError("cannot consume this Producer");const h=new g({id:e,producerId:t,kind:r,rtpParameters:l,streamId:i,onRtpReceiver:n,appData:o});return this._pendingConsumerTasks.push(h),(0,a.default)((()=>{this._closed||!1===this._consumerCreationInProgress&&this.createPendingConsumers()})),h.promise}async produceData({ordered:e=!0,maxPacketLifeTime:t,maxRetransmits:r,label:s="",protocol:i="",appData:a={}}={}){if(f.debug("produceData()"),this._closed)throw new c.InvalidStateError("closed");if("send"!==this._direction)throw new c.UnsupportedError("not a sending Transport");if(!this._maxSctpMessageSize)throw new c.UnsupportedError("SCTP not enabled by remote Transport");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("producedata"))throw new TypeError('no "producedata" listener set into this transport');if(a&&"object"!=typeof a)throw new TypeError("if given, appData must be an object");return(t||r)&&(e=!1),this._awaitQueue.push((async()=>{const{dataChannel:n,sctpStreamParameters:o}=await this._handler.sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:s,protocol:i});p.validateSctpStreamParameters(o);const{id:c}=await new Promise(((e,t)=>{this.safeEmit("producedata",{sctpStreamParameters:o,label:s,protocol:i,appData:a},e,t)})),d=new u.DataProducer({id:c,dataChannel:n,sctpStreamParameters:o,appData:a});return this._dataProducers.set(d.id,d),this.handleDataProducer(d),this._observer.safeEmit("newdataproducer",d),d}),"transport.produceData()")}async consumeData({id:e,dataProducerId:t,sctpStreamParameters:r,label:s="",protocol:i="",appData:a={}}){if(f.debug("consumeData()"),this._closed)throw new c.InvalidStateError("closed");if("recv"!==this._direction)throw new c.UnsupportedError("not a receiving Transport");if(!this._maxSctpMessageSize)throw new c.UnsupportedError("SCTP not enabled by remote Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing dataProducerId");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(a&&"object"!=typeof a)throw new TypeError("if given, appData must be an object");const n=d.clone(r);return p.validateSctpStreamParameters(n),this._awaitQueue.push((async()=>{const{dataChannel:r}=await this._handler.receiveDataChannel({sctpStreamParameters:n,label:s,protocol:i}),o=new m.DataConsumer({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:n,appData:a});return this._dataConsumers.set(o.id,o),this.handleDataConsumer(o),this._observer.safeEmit("newdataconsumer",o),o}),"transport.consumeData()")}async createPendingConsumers(){this._consumerCreationInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingConsumerTasks.length)return void f.debug("createPendingConsumers() | there is no Consumer to be created");const e=[...this._pendingConsumerTasks];let t;this._pendingConsumerTasks=[];const r=[];for(const i of e){const{id:e,kind:t,rtpParameters:s,streamId:a,onRtpReceiver:n}=i.consumerOptions;r.push({trackId:e,kind:t,rtpParameters:s,streamId:a,onRtpReceiver:n})}try{const s=await this._handler.receive(r);for(let r=0;r<s.length;++r){const i=e[r],a=s[r],{id:n,producerId:o,kind:c,rtpParameters:d,appData:p}=i.consumerOptions,{localId:l,rtpReceiver:u,track:m}=a,f=new h.Consumer({id:n,localId:l,producerId:o,rtpReceiver:u,track:m,rtpParameters:d,appData:p});this._consumers.set(f.id,f),this.handleConsumer(f),this._probatorConsumerCreated||t||"video"!==c||(t=f),this._observer.safeEmit("newconsumer",f),i.resolve(f)}}catch(s){for(const t of e)t.reject(s)}if(t)try{const e=p.generateProbatorRtpParameters(t.rtpParameters);await this._handler.receive([{trackId:"probator",kind:"video",rtpParameters:e}]),f.debug("createPendingConsumers() | Consumer for RTP probation created"),this._probatorConsumerCreated=!0}catch(s){f.error("createPendingConsumers() | failed to create Consumer for RTP probation:%o",s)}}),"transport.createPendingConsumers()").then((()=>{this._consumerCreationInProgress=!1,this._pendingConsumerTasks.length>0&&this.createPendingConsumers()})).catch((()=>{}))}pausePendingConsumers(){this._consumerPauseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingPauseConsumers.size)return void f.debug("pausePendingConsumers() | there is no Consumer to be paused");const e=Array.from(this._pendingPauseConsumers.values());this._pendingPauseConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.pauseReceiving(t)}catch(t){f.error("pausePendingConsumers() | failed to pause Consumers:",t)}}),"transport.pausePendingConsumers").then((()=>{this._consumerPauseInProgress=!1,this._pendingPauseConsumers.size>0&&this.pausePendingConsumers()})).catch((()=>{}))}resumePendingConsumers(){this._consumerResumeInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingResumeConsumers.size)return void f.debug("resumePendingConsumers() | there is no Consumer to be resumed");const e=Array.from(this._pendingResumeConsumers.values());this._pendingResumeConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.resumeReceiving(t)}catch(t){f.error("resumePendingConsumers() | failed to resume Consumers:",t)}}),"transport.resumePendingConsumers").then((()=>{this._consumerResumeInProgress=!1,this._pendingResumeConsumers.size>0&&this.resumePendingConsumers()})).catch((()=>{}))}closePendingConsumers(){this._consumerCloseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingCloseConsumers.size)return void f.debug("closePendingConsumers() | there is no Consumer to be closed");const e=Array.from(this._pendingCloseConsumers.values());this._pendingCloseConsumers.clear();try{await this._handler.stopReceiving(e.map((e=>e.localId)))}catch(t){f.error("closePendingConsumers() | failed to close Consumers:",t)}}),"transport.closePendingConsumers").then((()=>{this._consumerCloseInProgress=!1,this._pendingCloseConsumers.size>0&&this.closePendingConsumers()})).catch((()=>{}))}handleHandler(){const e=this._handler;e.on("@connect",(({dtlsParameters:e},t,r)=>{this._closed?r(new c.InvalidStateError("closed")):this.safeEmit("connect",{dtlsParameters:e},t,r)})),e.on("@icegatheringstatechange",(e=>{e!==this._iceGatheringState&&(f.debug("ICE gathering state changed to %s",e),this._iceGatheringState=e,this._closed||this.safeEmit("icegatheringstatechange",e))})),e.on("@connectionstatechange",(e=>{e!==this._connectionState&&(f.debug("connection state changed to %s",e),this._connectionState=e,this._closed||this.safeEmit("connectionstatechange",e))}))}handleProducer(e){e.on("@close",(()=>{this._producers.delete(e.id),this._closed||this._awaitQueue.push((async()=>await this._handler.stopSending(e.localId)),"producer @close event").catch((e=>f.warn("producer.close() failed:%o",e)))})),e.on("@pause",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.pauseSending(e.localId)),"producer @pause event").then(t).catch(r)})),e.on("@resume",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.resumeSending(e.localId)),"producer @resume event").then(t).catch(r)})),e.on("@replacetrack",((t,r,s)=>{this._awaitQueue.push((async()=>await this._handler.replaceTrack(e.localId,t)),"producer @replacetrack event").then(r).catch(s)})),e.on("@setmaxspatiallayer",((t,r,s)=>{this._awaitQueue.push((async()=>await this._handler.setMaxSpatialLayer(e.localId,t)),"producer @setmaxspatiallayer event").then(r).catch(s)})),e.on("@setrtpencodingparameters",((t,r,s)=>{this._awaitQueue.push((async()=>await this._handler.setRtpEncodingParameters(e.localId,t)),"producer @setrtpencodingparameters event").then(r).catch(s)})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new c.InvalidStateError("closed"));this._handler.getSenderStats(e.localId).then(t).catch(r)}))}handleConsumer(e){e.on("@close",(()=>{this._consumers.delete(e.id),this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.delete(e.id),this._closed||(this._pendingCloseConsumers.set(e.id,e),!1===this._consumerCloseInProgress&&this.closePendingConsumers())})),e.on("@pause",(()=>{this._pendingResumeConsumers.has(e.id)&&this._pendingResumeConsumers.delete(e.id),this._pendingPauseConsumers.set(e.id,e),(0,a.default)((()=>{this._closed||!1===this._consumerPauseInProgress&&this.pausePendingConsumers()}))})),e.on("@resume",(()=>{this._pendingPauseConsumers.has(e.id)&&this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.set(e.id,e),(0,a.default)((()=>{this._closed||!1===this._consumerResumeInProgress&&this.resumePendingConsumers()}))})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new c.InvalidStateError("closed"));this._handler.getReceiverStats(e.localId).then(t).catch(r)}))}handleDataProducer(e){e.on("@close",(()=>{this._dataProducers.delete(e.id)}))}handleDataConsumer(e){e.on("@close",(()=>{this._dataConsumers.delete(e.id)}))}}return V.Transport=b,V}var oe,ce,de,pe,le,he={},ue={},me={},fe={exports:{}};function ge(){if(oe)return fe.exports;oe=1;var e=fe.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"]}]};return Object.keys(e).forEach((function(t){e[t].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),fe.exports}function be(){return ce||(ce=1,function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,s){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var a=e.push?{}:i?r[e.name]:r;!function(e,r,s,i){if(i&&!s)r[i]=t(e[1]);else for(var a=0;a<s.length;a+=1)null!=e[a+1]&&(r[s[a]]=t(e[a+1]))}(s.match(e.reg),a,e.names,e.name),e.push&&r[e.push].push(a)},s=ge(),i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},a=[],n=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(a.push({rtp:[],fmtp:[]}),n=a[a.length-1]);for(var o=0;o<(s[t]||[]).length;o+=1){var c=s[t][o];if(c.reg.test(i))return r(c,n,i)}})),t.media=a,t};var a=function(e,r){var s=r.split(/=(.+)/,2);return 2===s.length?e[s[0]]=t(s[1]):1===s.length&&r.length>1&&(e[s[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],s=e.split(" ").map(t),i=0;i<s.length;i+=3)r.push({component:s[i],ip:s[i+1],port:s[i+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,s=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),s=!0),{scid:r,paused:s}}))}))}}(me)),me}function _e(){if(pe)return de;pe=1;var e=ge(),t=/%[sdv%]/g,r=function(e){var r=1,s=arguments,i=s.length;return e.replace(t,(function(e){if(r>=i)return e;var t=s[r];switch(r+=1,e){case"%%":return"%";case"%s":return String(t);case"%d":return Number(t);case"%v":return""}}))},s=function(e,t,s){var i=[e+"="+(t.format instanceof Function?t.format(t.push?s:s[t.name]):t.format)];if(t.names)for(var a=0;a<t.names.length;a+=1){var n=t.names[a];t.name?i.push(s[t.name][n]):i.push(s[t.names[a]])}else i.push(s[t.name]);return r.apply(null,i)},i=["v","o","s","i","u","e","p","c","b","t","r","z","a"],a=["i","c","b","a"];return de=function(t,r){r=r||{},null==t.version&&(t.version=0),null==t.name&&(t.name=" "),t.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var n=r.outerOrder||i,o=r.innerOrder||a,c=[];return n.forEach((function(r){e[r].forEach((function(e){e.name in t&&null!=t[e.name]?c.push(s(r,e,t)):e.push in t&&null!=t[e.push]&&t[e.push].forEach((function(t){c.push(s(r,e,t))}))}))})),t.media.forEach((function(t){c.push(s("m",e.m[0],t)),o.forEach((function(r){e[r].forEach((function(e){e.name in t&&null!=t[e.name]?c.push(s(r,e,t)):e.push in t&&null!=t[e.push]&&t[e.push].forEach((function(t){c.push(s(r,e,t))}))}))}))})),c.join("\r\n")+"\r\n"}}function ye(){if(le)return ue;le=1;var e=be(),t=_e();return ue.write=t,ue.parse=e.parse,ue.parseParams=e.parseParams,ue.parseFmtpConfig=e.parseFmtpConfig,ue.parsePayloads=e.parsePayloads,ue.parseRemoteCandidates=e.parseRemoteCandidates,ue.parseImageAttributes=e.parseImageAttributes,ue.parseSimulcastStreamList=e.parseSimulcastStreamList,ue}var we,ve={};function Se(){if(we)return ve;we=1;var e=ve&&ve.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=ve&&ve.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=ve&&ve.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(ve,"__esModule",{value:!0}),ve.extractRtpCapabilities=function({sdpObject:e}){const t=new Map,r=[];let i=!1,a=!1;for(const n of e.media){const e=n.type;switch(e){case"audio":if(i)continue;i=!0;break;case"video":if(a)continue;a=!0;break;default:continue}for(const r of n.rtp){const s={kind:e,mimeType:`${e}/${r.codec}`,preferredPayloadType:r.payload,clockRate:r.rate,channels:r.encoding,parameters:{},rtcpFeedback:[]};t.set(s.preferredPayloadType,s)}for(const r of n.fmtp||[]){const e=s.parseParams(r.config),i=t.get(r.payload);i&&(e&&e.hasOwnProperty("profile-level-id")&&(e["profile-level-id"]=String(e["profile-level-id"])),i.parameters=e)}for(const r of n.rtcpFb||[]){const s={type:r.type,parameter:r.subtype};if(s.parameter||delete s.parameter,"*"!==r.payload){const e=t.get(r.payload);if(!e)continue;e.rtcpFeedback.push(s)}else for(const r of t.values())r.kind!==e||/.+\/rtx$/i.test(r.mimeType)||r.rtcpFeedback.push(s)}for(const t of n.ext||[]){if(t["encrypt-uri"])continue;const s={kind:e,uri:t.uri,preferredId:t.value};r.push(s)}}return{codecs:Array.from(t.values()),headerExtensions:r}},ve.extractDtlsParameters=function({sdpObject:e}){let t,r=e.setup,s=e.fingerprint;if(!r||!s){const t=(e.media||[]).find((e=>0!==e.port));t&&(r??(r=t.setup),s??(s=t.fingerprint))}if(!r)throw new Error("no a=setup found at SDP session or media level");if(!s)throw new Error("no a=fingerprint found at SDP session or media level");switch(r){case"active":t="client";break;case"passive":t="server";break;case"actpass":t="auto"}return{role:t,fingerprints:[{algorithm:s.type,value:s.hash}]}},ve.getCname=function({offerMediaObject:e}){const t=(e.ssrcs||[]).find((e=>"cname"===e.attribute));if(!t)return"";return t.value},ve.applyCodecParameters=function({offerRtpParameters:e,answerMediaObject:t}){for(const r of e.codecs){const e=r.mimeType.toLowerCase();if("audio/opus"!==e)continue;if(!(t.rtp||[]).find((e=>e.payload===r.payloadType)))continue;t.fmtp=t.fmtp||[];let i=t.fmtp.find((e=>e.payload===r.payloadType));i||(i={payload:r.payloadType,config:""},t.fmtp.push(i));const a=s.parseParams(i.config);switch(e){case"audio/opus":{const e=r.parameters["sprop-stereo"];void 0!==e&&(a.stereo=e?1:0);break}}i.config="";for(const t of Object.keys(a))i.config&&(i.config+=";"),i.config+=`${t}=${a[t]}`}};const s=r(ye());return ve}var Re,Pe={};function Ce(){if(Re)return Pe;return Re=1,Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.getRtpEncodings=function({offerMediaObject:e}){const t=new Set;for(const i of e.ssrcs||[]){const e=i.id;t.add(e)}if(0===t.size)throw new Error("no a=ssrc lines found");const r=new Map;for(const i of e.ssrcGroups||[]){if("FID"!==i.semantics)continue;let[e,s]=i.ssrcs.split(/\s+/);e=Number(e),s=Number(s),t.has(e)&&(t.delete(e),t.delete(s),r.set(e,s))}for(const i of t)r.set(i,null);const s=[];for(const[i,a]of r){const e={ssrc:i};a&&(e.rtx={ssrc:a}),s.push(e)}return s},Pe.addLegacySimulcast=function({offerMediaObject:e,numStreams:t}){if(t<=1)throw new TypeError("numStreams must be greater than 1");const r=(e.ssrcs||[]).find((e=>"msid"===e.attribute));if(!r)throw new Error("a=ssrc line with msid information not found");const[s,i]=r.value.split(" "),a=r.id;let n;(e.ssrcGroups||[]).some((e=>{if("FID"!==e.semantics)return!1;const t=e.ssrcs.split(/\s+/);return Number(t[0])===a&&(n=Number(t[1]),!0)}));const o=e.ssrcs.find((e=>"cname"===e.attribute));if(!o)throw new Error("a=ssrc line with cname information not found");const c=o.value,d=[],p=[];for(let l=0;l<t;++l)d.push(a+l),n&&p.push(n+l);e.ssrcGroups=[],e.ssrcs=[],e.ssrcGroups.push({semantics:"SIM",ssrcs:d.join(" ")});for(let l=0;l<d.length;++l){const t=d[l];e.ssrcs.push({id:t,attribute:"cname",value:c}),e.ssrcs.push({id:t,attribute:"msid",value:`${s} ${i}`})}for(let l=0;l<p.length;++l){const t=d[l],r=p[l];e.ssrcs.push({id:r,attribute:"cname",value:c}),e.ssrcs.push({id:r,attribute:"msid",value:`${s} ${i}`}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`})}},Pe}var ke,Te={};function De(){if(ke)return Te;return ke=1,Object.defineProperty(Te,"__esModule",{value:!0}),Te.addNackSuppportForOpus=function(e){for(const t of e.codecs||[])"audio/opus"!==t.mimeType.toLowerCase()&&"audio/multiopus"!==t.mimeType.toLowerCase()||t.rtcpFeedback?.some((e=>"nack"===e.type&&!e.parameter))||(t.rtcpFeedback||(t.rtcpFeedback=[]),t.rtcpFeedback.push({type:"nack"}))},Te}var Ee,Ie={};function xe(){if(Ee)return Ie;Ee=1,Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.HandlerInterface=void 0;const e=P();let t=class extends e.EnhancedEventEmitter{constructor(){super()}};return Ie.HandlerInterface=t,Ie}var Me,Oe,Le={},Ae={};function je(){if(Oe)return Le;Oe=1;var e=Le&&Le.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=Le&&Le.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=Le&&Le.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(Le,"__esModule",{value:!0}),Le.RemoteSdp=void 0;const s=r(ye()),i=_(),a=function(){if(Me)return Ae;Me=1;var e=Ae&&Ae.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=Ae&&Ae.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=Ae&&Ae.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.OfferMediaSection=Ae.AnswerMediaSection=Ae.MediaSection=void 0;const s=r(ye()),i=r(I());let a=class{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:s=!1}){if(this._mediaObject={},this._planB=s,e&&this.setIceParameters(e),t){this._mediaObject.candidates=[];for(const e of t){const t={component:1};t.foundation=e.foundation,t.ip=e.address??e.ip,t.port=e.port,t.priority=e.priority,t.transport=e.protocol,t.type=e.type,e.tcpType&&(t.tcptype=e.tcpType),this._mediaObject.candidates.push(t)}this._mediaObject.endOfCandidates="end-of-candidates",this._mediaObject.iceOptions="renomination"}r&&this.setDtlsRole(r.role)}get mid(){return String(this._mediaObject.mid)}get closed(){return 0===this._mediaObject.port}getObject(){return this._mediaObject}setIceParameters(e){this._mediaObject.iceUfrag=e.usernameFragment,this._mediaObject.icePwd=e.password}pause(){this._mediaObject.direction="inactive"}disable(){this.pause(),delete this._mediaObject.ext,delete this._mediaObject.ssrcs,delete this._mediaObject.ssrcGroups,delete this._mediaObject.simulcast,delete this._mediaObject.simulcast_03,delete this._mediaObject.rids,delete this._mediaObject.extmapAllowMixed}close(){this.disable(),this._mediaObject.port=0}};function n(e){const t=new RegExp("^(audio|video)/(.+)","i").exec(e.mimeType);if(!t)throw new TypeError("invalid codec.mimeType");return t[2]}return Ae.MediaSection=a,Ae.AnswerMediaSection=class extends a{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:s,plainRtpParameters:a,planB:o=!1,offerMediaObject:c,offerRtpParameters:d,answerRtpParameters:p,codecOptions:l,extmapAllowMixed:h=!1}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:o}),this._mediaObject.mid=String(c.mid),this._mediaObject.type=c.type,this._mediaObject.protocol=c.protocol,a?(this._mediaObject.connection={ip:a.ip,version:a.ipVersion},this._mediaObject.port=a.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.port=7),c.type){case"audio":case"video":this._mediaObject.direction="recvonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[];for(const e of p.codecs){const t={payload:e.payloadType,codec:n(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r=i.clone(e.parameters)??{};let s=i.clone(e.rtcpFeedback)??[];if(l){const{opusStereo:t,opusFec:i,opusDtx:a,opusMaxPlaybackRate:n,opusMaxAverageBitrate:o,opusPtime:c,opusNack:p,videoGoogleStartBitrate:h,videoGoogleMaxBitrate:u,videoGoogleMinBitrate:m}=l,f=d.codecs.find((t=>t.payloadType===e.payloadType));switch(e.mimeType.toLowerCase()){case"audio/opus":case"audio/multiopus":void 0!==t&&(f.parameters["sprop-stereo"]=t?1:0,r.stereo=t?1:0),void 0!==i&&(f.parameters.useinbandfec=i?1:0,r.useinbandfec=i?1:0),void 0!==a&&(f.parameters.usedtx=a?1:0,r.usedtx=a?1:0),void 0!==n&&(r.maxplaybackrate=n),void 0!==o&&(r.maxaveragebitrate=o),void 0!==c&&(f.parameters.ptime=c,r.ptime=c),p||(f.rtcpFeedback=f.rtcpFeedback.filter((e=>"nack"!==e.type||e.parameter)),s=s.filter((e=>"nack"!==e.type||e.parameter)));break;case"video/vp8":case"video/vp9":case"video/h264":case"video/h265":void 0!==h&&(r["x-google-start-bitrate"]=h),void 0!==u&&(r["x-google-max-bitrate"]=u),void 0!==m&&(r["x-google-min-bitrate"]=m)}}const a={payload:e.payloadType,config:""};for(const e of Object.keys(r))a.config&&(a.config+=";"),a.config+=`${e}=${r[e]}`;a.config&&this._mediaObject.fmtp.push(a);for(const i of s)this._mediaObject.rtcpFb.push({payload:e.payloadType,type:i.type,subtype:i.parameter})}this._mediaObject.payloads=p.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of p.headerExtensions)(c.ext||[]).some((t=>t.uri===e.uri))&&this._mediaObject.ext.push({uri:e.uri,value:e.id});if(h&&"extmap-allow-mixed"===c.extmapAllowMixed&&(this._mediaObject.extmapAllowMixed="extmap-allow-mixed"),c.simulcast){this._mediaObject.simulcast={dir1:"recv",list1:c.simulcast.list1},this._mediaObject.rids=[];for(const e of c.rids||[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}else if(c.simulcast_03){this._mediaObject.simulcast_03={value:c.simulcast_03.value.replace(/send/g,"recv")},this._mediaObject.rids=[];for(const e of c.rids||[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize",this._planB&&"video"===this._mediaObject.type&&(this._mediaObject.xGoogleFlag="conference");break;case"application":"number"==typeof c.sctpPort?(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=s.port,this._mediaObject.maxMessageSize=s.maxMessageSize):c.sctpmap&&(this._mediaObject.payloads=s.port,this._mediaObject.sctpmap={app:"webrtc-datachannel",sctpmapNumber:s.port,maxMessageSize:s.maxMessageSize})}}setDtlsRole(e){switch(e){case"client":this._mediaObject.setup="active";break;case"server":this._mediaObject.setup="passive";break;case"auto":this._mediaObject.setup="actpass"}}resume(){this._mediaObject.direction="recvonly"}muxSimulcastStreams(e){if(!this._mediaObject.simulcast||!this._mediaObject.simulcast.list1)return;const t={};for(const s of e)s.rid&&(t[s.rid]=s);const r=this._mediaObject.simulcast.list1,i=s.parseSimulcastStreamList(r);for(const s of i)for(const e of s)e.paused=!t[e.scid]?.active;this._mediaObject.simulcast.list1=i.map((e=>e.map((e=>`${e.paused?"~":""}${e.scid}`)).join(","))).join(";")}},Ae.OfferMediaSection=class extends a{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:s,plainRtpParameters:i,planB:a=!1,mid:o,kind:c,offerRtpParameters:d,streamId:p,trackId:l,oldDataChannelSpec:h=!1}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:a}),this._mediaObject.mid=String(o),this._mediaObject.type=c,i?(this._mediaObject.connection={ip:i.ip,version:i.ipVersion},this._mediaObject.protocol="RTP/AVP",this._mediaObject.port=i.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.protocol=s?"UDP/DTLS/SCTP":"UDP/TLS/RTP/SAVPF",this._mediaObject.port=7),c){case"audio":case"video":{this._mediaObject.direction="sendonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[],this._planB||(this._mediaObject.msid=`${p||"-"} ${l}`);for(const s of d.codecs){const e={payload:s.payloadType,codec:n(s),rate:s.clockRate};s.channels>1&&(e.encoding=s.channels),this._mediaObject.rtp.push(e);const t={payload:s.payloadType,config:""};for(const r of Object.keys(s.parameters))t.config&&(t.config+=";"),t.config+=`${r}=${s.parameters[r]}`;t.config&&this._mediaObject.fmtp.push(t);for(const r of s.rtcpFeedback)this._mediaObject.rtcpFb.push({payload:s.payloadType,type:r.type,subtype:r.parameter})}this._mediaObject.payloads=d.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const s of d.headerExtensions)this._mediaObject.ext.push({uri:s.uri,value:s.id});this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize";const e=d.encodings[0],t=e.ssrc,r=e.rtx&&e.rtx.ssrc?e.rtx.ssrc:void 0;this._mediaObject.ssrcs=[],this._mediaObject.ssrcGroups=[],d.rtcp.cname&&this._mediaObject.ssrcs.push({id:t,attribute:"cname",value:d.rtcp.cname}),this._planB&&this._mediaObject.ssrcs.push({id:t,attribute:"msid",value:`${p||"-"} ${l}`}),r&&(d.rtcp.cname&&this._mediaObject.ssrcs.push({id:r,attribute:"cname",value:d.rtcp.cname}),this._planB&&this._mediaObject.ssrcs.push({id:r,attribute:"msid",value:`${p||"-"} ${l}`}),this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}));break}case"application":h?(this._mediaObject.payloads=s.port,this._mediaObject.sctpmap={app:"webrtc-datachannel",sctpmapNumber:s.port,maxMessageSize:s.maxMessageSize}):(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=s.port,this._mediaObject.maxMessageSize=s.maxMessageSize)}}setDtlsRole(e){this._mediaObject.setup="actpass"}resume(){this._mediaObject.direction="sendonly"}planBReceive({offerRtpParameters:e,streamId:t,trackId:r}){const s=e.encodings[0],i=s.ssrc,a=s.rtx&&s.rtx.ssrc?s.rtx.ssrc:void 0,o=this._mediaObject.payloads.split(" ");for(const c of e.codecs){if(o.includes(String(c.payloadType)))continue;const e={payload:c.payloadType,codec:n(c),rate:c.clockRate};c.channels>1&&(e.encoding=c.channels),this._mediaObject.rtp.push(e);const t={payload:c.payloadType,config:""};for(const r of Object.keys(c.parameters))t.config&&(t.config+=";"),t.config+=`${r}=${c.parameters[r]}`;t.config&&this._mediaObject.fmtp.push(t);for(const r of c.rtcpFeedback)this._mediaObject.rtcpFb.push({payload:c.payloadType,type:r.type,subtype:r.parameter})}this._mediaObject.payloads+=` ${e.codecs.filter((e=>!this._mediaObject.payloads.includes(e.payloadType))).map((e=>e.payloadType)).join(" ")}`,this._mediaObject.payloads=this._mediaObject.payloads.trim(),e.rtcp.cname&&this._mediaObject.ssrcs.push({id:i,attribute:"cname",value:e.rtcp.cname}),this._mediaObject.ssrcs.push({id:i,attribute:"msid",value:`${t||"-"} ${r}`}),a&&(e.rtcp.cname&&this._mediaObject.ssrcs.push({id:a,attribute:"cname",value:e.rtcp.cname}),this._mediaObject.ssrcs.push({id:a,attribute:"msid",value:`${t||"-"} ${r}`}),this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${i} ${a}`}))}planBStopReceiving({offerRtpParameters:e}){const t=e.encodings[0],r=t.ssrc,s=t.rtx&&t.rtx.ssrc?t.rtx.ssrc:void 0;this._mediaObject.ssrcs=this._mediaObject.ssrcs.filter((e=>e.id!==r&&e.id!==s)),s&&(this._mediaObject.ssrcGroups=this._mediaObject.ssrcGroups.filter((e=>e.ssrcs!==`${r} ${s}`)))}},Ae}(),n=new i.Logger("RemoteSdp");return Le.RemoteSdp=class{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:s,plainRtpParameters:i,planB:a=!1}){if(this._mediaSections=[],this._midToIndex=new Map,this._iceParameters=e,this._iceCandidates=t,this._dtlsParameters=r,this._sctpParameters=s,this._plainRtpParameters=i,this._planB=a,this._sdpObject={version:0,origin:{address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:1e4,sessionVersion:0,username:"mediasoup-client"},name:"-",timing:{start:0,stop:0},media:[]},e&&e.iceLite&&(this._sdpObject.icelite="ice-lite"),r){this._sdpObject.msidSemantic={semantic:"WMS",token:"*"};const e=this._dtlsParameters.fingerprints.length;this._sdpObject.fingerprint={type:r.fingerprints[e-1].algorithm,hash:r.fingerprints[e-1].value},this._sdpObject.groups=[{type:"BUNDLE",mids:""}]}i&&(this._sdpObject.origin.address=i.ip,this._sdpObject.origin.ipVer=i.ipVersion)}updateIceParameters(e){n.debug("updateIceParameters() [iceParameters:%o]",e),this._iceParameters=e,this._sdpObject.icelite=e.iceLite?"ice-lite":void 0;for(const t of this._mediaSections)t.setIceParameters(e)}updateDtlsRole(e){n.debug("updateDtlsRole() [role:%s]",e),this._dtlsParameters.role=e;for(const t of this._mediaSections)t.setDtlsRole(e)}getNextMediaSectionIdx(){for(let e=0;e<this._mediaSections.length;++e){const t=this._mediaSections[e];if(t.closed)return{idx:e,reuseMid:t.mid}}return{idx:this._mediaSections.length}}send({offerMediaObject:e,reuseMid:t,offerRtpParameters:r,answerRtpParameters:s,codecOptions:i,extmapAllowMixed:n=!1}){const o=new a.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,planB:this._planB,offerMediaObject:e,offerRtpParameters:r,answerRtpParameters:s,codecOptions:i,extmapAllowMixed:n});t?this._replaceMediaSection(o,t):this._midToIndex.has(o.mid)?this._replaceMediaSection(o):this._addMediaSection(o)}receive({mid:e,kind:t,offerRtpParameters:r,streamId:s,trackId:i}){const n=this._midToIndex.get(e);let o;if(void 0!==n&&(o=this._mediaSections[n]),o)o.planBReceive({offerRtpParameters:r,streamId:s,trackId:i}),this._replaceMediaSection(o);else{o=new a.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,planB:this._planB,mid:e,kind:t,offerRtpParameters:r,streamId:s,trackId:i});const n=this._mediaSections.find((e=>e.closed));n?this._replaceMediaSection(o,n.mid):this._addMediaSection(o)}}pauseMediaSection(e){this._findMediaSection(e).pause()}resumeSendingMediaSection(e){this._findMediaSection(e).resume()}resumeReceivingMediaSection(e){this._findMediaSection(e).resume()}disableMediaSection(e){this._findMediaSection(e).disable()}closeMediaSection(e){const t=this._findMediaSection(e);return e===this._firstMid?(n.debug("closeMediaSection() | cannot close first media section, disabling it instead [mid:%s]",e),this.disableMediaSection(e),!1):(t.close(),this._regenerateBundleMids(),!0)}muxMediaSectionSimulcast(e,t){const r=this._findMediaSection(e);r.muxSimulcastStreams(t),this._replaceMediaSection(r)}planBStopReceiving({mid:e,offerRtpParameters:t}){const r=this._findMediaSection(e);r.planBStopReceiving({offerRtpParameters:t}),this._replaceMediaSection(r)}sendSctpAssociation({offerMediaObject:e}){const t=new a.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,offerMediaObject:e});this._addMediaSection(t)}receiveSctpAssociation({oldDataChannelSpec:e=!1}={}){const t=new a.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,mid:"datachannel",kind:"application",oldDataChannelSpec:e});this._addMediaSection(t)}getSdp(){return this._sdpObject.origin.sessionVersion++,s.write(this._sdpObject)}_addMediaSection(e){this._firstMid||(this._firstMid=e.mid),this._mediaSections.push(e),this._midToIndex.set(e.mid,this._mediaSections.length-1),this._sdpObject.media.push(e.getObject()),this._regenerateBundleMids()}_replaceMediaSection(e,t){if("string"==typeof t){const r=this._midToIndex.get(t);if(void 0===r)throw new Error(`no media section found for reuseMid '${t}'`);const s=this._mediaSections[r];this._mediaSections[r]=e,this._midToIndex.delete(s.mid),this._midToIndex.set(e.mid,r),this._sdpObject.media[r]=e.getObject(),this._regenerateBundleMids()}else{const t=this._midToIndex.get(e.mid);if(void 0===t)throw new Error(`no media section found with mid '${e.mid}'`);this._mediaSections[t]=e,this._sdpObject.media[t]=e.getObject()}}_findMediaSection(e){const t=this._midToIndex.get(e);if(void 0===t)throw new Error(`no media section found with mid '${e}'`);return this._mediaSections[t]}_regenerateBundleMids(){this._dtlsParameters&&(this._sdpObject.groups[0].mids=this._mediaSections.filter((e=>!e.closed)).map((e=>e.mid)).join(" "))}},Le}var Ne,Be,Fe={};function $e(){if(Ne)return Fe;Ne=1,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.parse=function(t){const r=e.exec(t||"");return r?{spatialLayers:Number(r[1]),temporalLayers:Number(r[2])}:{spatialLayers:1,temporalLayers:1}};const e=new RegExp("^[LS]([1-9]\\d{0,1})T([1-9]\\d{0,1})");return Fe}var Ue,qe={};var Ve,We={};var Ke,He,Ge={},ze={};function Je(){if(Ke)return ze;return Ke=1,Object.defineProperty(ze,"__esModule",{value:!0}),ze.getRtpEncodings=function({offerMediaObject:e,track:t}){const r=new Set;for(const a of e.ssrcs||[]){if("msid"!==a.attribute)continue;if(a.value.split(" ")[1]===t.id){const e=a.id;r.add(e)}}if(0===r.size)throw new Error(`a=ssrc line with msid information not found [track.id:${t.id}]`);const s=new Map;for(const a of e.ssrcGroups||[]){if("FID"!==a.semantics)continue;let[e,t]=a.ssrcs.split(/\s+/);e=Number(e),t=Number(t),r.has(e)&&(r.delete(e),r.delete(t),s.set(e,t))}for(const a of r)s.set(a,null);const i=[];for(const[a,n]of s){const e={ssrc:a};n&&(e.rtx={ssrc:n}),i.push(e)}return i},ze.addLegacySimulcast=function({offerMediaObject:e,track:t,numStreams:r}){if(r<=1)throw new TypeError("numStreams must be greater than 1");let s,i,a;if(!(e.ssrcs||[]).find((e=>{if("msid"!==e.attribute)return!1;return e.value.split(" ")[1]===t.id&&(s=e.id,a=e.value.split(" ")[0],!0)})))throw new Error(`a=ssrc line with msid information not found [track.id:${t.id}]`);(e.ssrcGroups||[]).some((e=>{if("FID"!==e.semantics)return!1;const t=e.ssrcs.split(/\s+/);return Number(t[0])===s&&(i=Number(t[1]),!0)}));const n=e.ssrcs.find((e=>"cname"===e.attribute&&e.id===s));if(!n)throw new Error(`a=ssrc line with cname information not found [track.id:${t.id}]`);const o=n.value,c=[],d=[];for(let p=0;p<r;++p)c.push(s+p),i&&d.push(i+p);e.ssrcGroups=e.ssrcGroups||[],e.ssrcs=e.ssrcs||[],e.ssrcGroups.push({semantics:"SIM",ssrcs:c.join(" ")});for(let p=0;p<c.length;++p){const r=c[p];e.ssrcs.push({id:r,attribute:"cname",value:o}),e.ssrcs.push({id:r,attribute:"msid",value:`${a} ${t.id}`})}for(let p=0;p<d.length;++p){const r=c[p],s=d[p];e.ssrcs.push({id:s,attribute:"cname",value:o}),e.ssrcs.push({id:s,attribute:"msid",value:`${a} ${t.id}`}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${r} ${s}`})}},ze}var Qe,Xe={};var Ye,Ze={};var et,tt={};var rt,st={};var it,at={};var nt,ot,ct={},dt={};function pt(){if(ot)return ct;ot=1;var e=ct&&ct.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=ct&&ct.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=ct&&ct.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(ct,"__esModule",{value:!0}),ct.Edge11=void 0;const s=_(),i=T(),a=r(I()),n=r(B()),o=r(function(){if(nt)return dt;nt=1;var e=dt&&dt.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=dt&&dt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=dt&&dt.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(dt,"__esModule",{value:!0}),dt.getCapabilities=function(){const e=RTCRtpReceiver.getCapabilities(),t=s.clone(e);for(const r of t.codecs??[]){if(r.channels=r.numChannels,delete r.numChannels,r.mimeType=r.mimeType||`${r.kind}/${r.name}`,r.parameters){const e=r.parameters;e.apt&&(e.apt=Number(e.apt)),e["packetization-mode"]&&(e["packetization-mode"]=Number(e["packetization-mode"]))}for(const e of r.rtcpFeedback||[])e.parameter||(e.parameter="")}return t},dt.mangleRtpParameters=function(e){const t=s.clone(e);t.mid&&(t.muxId=t.mid,delete t.mid);for(const r of t.codecs)r.channels&&(r.numChannels=r.channels,delete r.channels),r.mimeType&&!r.name&&(r.name=r.mimeType.split("/")[1]),delete r.mimeType;return t};const s=r(I());return dt}()),c=xe(),d=new s.Logger("Edge11");let p=class e extends c.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._rtpSenders=new Map,this._rtpReceivers=new Map,this._nextSendLocalId=0,this._transportReady=!1}get name(){return"Edge11"}close(){d.debug("close()");try{this._iceGatherer.close()}catch(e){}try{this._iceTransport.stop()}catch(e){}try{this._dtlsTransport.stop()}catch(e){}for(const t of this._rtpSenders.values())try{t.stop()}catch(e){}for(const t of this._rtpReceivers.values())try{t.stop()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){return d.debug("getNativeRtpCapabilities()"),o.getCapabilities()}async getNativeSctpCapabilities(){return d.debug("getNativeSctpCapabilities()"),{numStreams:{OS:0,MIS:0}}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:o,iceTransportPolicy:c,additionalSettings:p,proprietaryConstraints:l,extendedRtpCapabilities:h}){d.debug("run()"),this._sendingRtpParametersByKind={audio:n.getSendingRtpParameters("audio",h),video:n.getSendingRtpParameters("video",h)},this._remoteIceParameters=t,this._remoteIceCandidates=r,this._remoteDtlsParameters=s,this._cname=`CNAME-${a.generateRandomNumber()}`,this.setIceGatherer({iceServers:o,iceTransportPolicy:c}),this.setIceTransport(),this.setDtlsTransport()}async updateIceServers(e){throw new i.UnsupportedError("not supported")}async restartIce(e){if(d.debug("restartIce()"),this._remoteIceParameters=e,this._transportReady){d.debug("restartIce() | calling iceTransport.start()"),this._iceTransport.start(this._iceGatherer,e,"controlling");for(const e of this._remoteIceCandidates)this._iceTransport.addRemoteCandidate(e);this._iceTransport.addRemoteCandidate({})}}async getTransportStats(){return this._iceTransport.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:s}){d.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),this._transportReady||await this.setupTransport({localDtlsRole:"server"}),d.debug("send() | calling new RTCRtpSender()");const i=new RTCRtpSender(e,this._dtlsTransport),c=a.clone(this._sendingRtpParametersByKind[e.kind]);c.codecs=n.reduceCodecs(c.codecs,s);const p=c.codecs.some((e=>/.+\/rtx$/i.test(e.mimeType)));t||(t=[{}]);for(const n of t)n.ssrc=a.generateRandomNumber(),p&&(n.rtx={ssrc:a.generateRandomNumber()});c.encodings=t,c.rtcp={cname:this._cname,reducedSize:!0,mux:!0};const l=o.mangleRtpParameters(c);d.debug("send() | calling rtpSender.send() [params:%o]",l),await i.send(l);const h=String(this._nextSendLocalId);return this._nextSendLocalId++,this._rtpSenders.set(h,i),{localId:h,rtpParameters:c,rtpSender:i}}async stopSending(e){d.debug("stopSending() [localId:%s]",e);const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");this._rtpSenders.delete(e);try{d.debug("stopSending() | calling rtpSender.stop()"),t.stop()}catch(r){throw d.warn("stopSending() | rtpSender.stop() failed:%o",r),r}}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){t?d.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):d.debug("replaceTrack() [localId:%s, no track]",e);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");r.setTrack(t)}async setMaxSpatialLayer(e,t){d.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");const s=r.getParameters();s.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(s)}async setRtpEncodingParameters(e,t){d.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");const s=r.getParameters();s.encodings.forEach(((e,r)=>{s.encodings[r]={...e,...t}})),await r.setParameters(s)}async getSenderStats(e){const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");return t.getStats()}async sendDataChannel(e){throw new i.UnsupportedError("not implemented")}async receive(e){const t=[];for(const r of e){const{trackId:e,kind:t}=r;d.debug("receive() [trackId:%s, kind:%s]",e,t)}this._transportReady||await this.setupTransport({localDtlsRole:"server"});for(const r of e){const{trackId:e,kind:s,rtpParameters:i}=r;d.debug("receive() | calling new RTCRtpReceiver()");const a=new RTCRtpReceiver(this._dtlsTransport,s);a.addEventListener("error",(e=>{d.error('rtpReceiver "error" event [event:%o]',e)}));const n=o.mangleRtpParameters(i);d.debug("receive() | calling rtpReceiver.receive() [params:%o]",n),await a.receive(n);const c=e;this._rtpReceivers.set(c,a),t.push({localId:c,track:a.track,rtpReceiver:a})}return t}async stopReceiving(e){for(const r of e){d.debug("stopReceiving() [localId:%s]",r);const e=this._rtpReceivers.get(r);if(!e)throw new Error("RTCRtpReceiver not found");this._rtpReceivers.delete(r);try{d.debug("stopReceiving() | calling rtpReceiver.stop()"),e.stop()}catch(t){d.warn("stopReceiving() | rtpReceiver.stop() failed:%o",t)}}}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){const t=this._rtpReceivers.get(e);if(!t)throw new Error("RTCRtpReceiver not found");return t.getStats()}async receiveDataChannel(e){throw new i.UnsupportedError("not implemented")}setIceGatherer({iceServers:e,iceTransportPolicy:t}){const r=new RTCIceGatherer({iceServers:e||[],gatherPolicy:t||"all"});r.addEventListener("error",(e=>{d.error('iceGatherer "error" event [event:%o]',e)}));try{r.gather()}catch(s){d.debug("setIceGatherer() | iceGatherer.gather() failed: %s",s.toString())}this._iceGatherer=r}setIceTransport(){const e=new RTCIceTransport(this._iceGatherer);e.addEventListener("statechange",(()=>{switch(e.state){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})),e.addEventListener("icestatechange",(()=>{switch(e.state){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})),e.addEventListener("candidatepairchange",(e=>{d.debug('iceTransport "candidatepairchange" event [pair:%o]',e.pair)})),this._iceTransport=e}setDtlsTransport(){const e=new RTCDtlsTransport(this._iceTransport);e.addEventListener("statechange",(()=>{d.debug('dtlsTransport "statechange" event [state:%s]',e.state)})),e.addEventListener("dtlsstatechange",(()=>{d.debug('dtlsTransport "dtlsstatechange" event [state:%s]',e.state),"closed"===e.state&&this.emit("@connectionstatechange","closed")})),e.addEventListener("error",(e=>{d.error('dtlsTransport "error" event [event:%o]',e)})),this._dtlsTransport=e}async setupTransport({localDtlsRole:e}){d.debug("setupTransport()");const t=this._dtlsTransport.getLocalParameters();t.role=e,await new Promise(((e,r)=>{this.safeEmit("@connect",{dtlsParameters:t},e,r)})),this._iceTransport.start(this._iceGatherer,this._remoteIceParameters,"controlling");for(const r of this._remoteIceCandidates)this._iceTransport.addRemoteCandidate(r);this._iceTransport.addRemoteCandidate({}),this._remoteDtlsParameters.fingerprints=this._remoteDtlsParameters.fingerprints.filter((e=>"sha-256"===e.algorithm||"sha-384"===e.algorithm||"sha-512"===e.algorithm)),this._dtlsTransport.start(this._remoteDtlsParameters),this._transportReady=!0}};return ct.Edge11=p,ct}var lt,ht={};var ut,mt,ft={};function gt(){if(mt)return h;mt=1;var e=h&&h.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=h&&h.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=h&&h.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(h,"__esModule",{value:!0}),h.Device=void 0,h.detectDevice=D;const s=f(),i=_(),a=P(),n=T(),o=r(I()),c=r(B()),d=ne(),p=function(){if(Be)return he;Be=1;var e=he&&he.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=he&&he.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=he&&he.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(he,"__esModule",{value:!0}),he.Chrome111=void 0;const s=r(ye()),i=_(),a=r(I()),n=r(B()),o=r(Se()),c=r(Ce()),d=r(De()),p=T(),l=xe(),h=je(),u=$e(),m=new i.Logger("Chrome111"),f={OS:1024,MIS:1024};let g=class e extends l.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome111"}close(){if(m.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){m.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const r=await e.createOffer();try{e.close()}catch(t){}const i=s.parse(r.sdp),a=o.extractRtpCapabilities({sdpObject:i});return d.addNackSuppportForOpus(a),a}catch(t){try{e.close()}catch(r){}throw t}}async getNativeSctpCapabilities(){return m.debug("getNativeSctpCapabilities()"),{numStreams:f}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:o,additionalSettings:c,proprietaryConstraints:d,extendedRtpCapabilities:p}){this.assertNotClosed(),m.debug("run()"),this._direction=e,this._remoteSdp=new h.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i}),this._sendingRtpParametersByKind={audio:n.getSendingRtpParameters("audio",p),video:n.getSendingRtpParameters("video",p)},this._sendingRemoteRtpParametersByKind={audio:n.getSendingRemoteRtpParameters("audio",p),video:n.getSendingRemoteRtpParameters("video",p)},s.role&&"auto"!==s.role&&(this._forcedLocalDtlsRole="server"===s.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:o||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...c},d),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):(m.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})))}async updateIceServers(e){this.assertNotClosed(),m.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),m.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});m.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();m.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i,onRtpSender:d}){if(this.assertNotClosed(),this.assertSendDirection(),m.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1){let e=1;for(const r of t){const t=r.scalabilityMode?(0,u.parse)(r.scalabilityMode).temporalLayers:3;t>e&&(e=t)}t.forEach(((t,r)=>{t.rid=`r${r}`,t.scalabilityMode=`L1T${e}`}))}const p=a.clone(this._sendingRtpParametersByKind[e.kind]);p.codecs=n.reduceCodecs(p.codecs,i);const l=a.clone(this._sendingRemoteRtpParametersByKind[e.kind]);l.codecs=n.reduceCodecs(l.codecs,i);const h=this._remoteSdp.getNextMediaSectionIdx(),f=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});d&&d(f.sender);const g=await this._pc.createOffer();let b=s.parse(g.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:b}),m.debug("send() | calling pc.setLocalDescription() [offer:%o]",g),await this._pc.setLocalDescription(g);const _=f.mid;p.mid=_,b=s.parse(this._pc.localDescription.sdp);const y=b.media[h.idx];if(p.rtcp.cname=o.getCname({offerMediaObject:y}),t)if(1===t.length){const e=c.getRtpEncodings({offerMediaObject:y});Object.assign(e[0],t[0]),p.encodings=e}else p.encodings=t;else p.encodings=c.getRtpEncodings({offerMediaObject:y});this._remoteSdp.send({offerMediaObject:y,reuseMid:h.reuseMid,offerRtpParameters:p,answerRtpParameters:l,codecOptions:r,extmapAllowMixed:!0});const w={type:"answer",sdp:this._remoteSdp.getSdp()};return m.debug("send() | calling pc.setRemoteDescription() [answer:%o]",w),await this._pc.setRemoteDescription(w),this._mapMidTransceiver.set(_,f),{localId:_,rtpParameters:p,rtpSender:f.sender}}async stopSending(e){if(this.assertSendDirection(),m.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");if(t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(i){}const r=await this._pc.createOffer();m.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),m.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();m.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),m.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();m.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?m.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):m.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),m.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();m.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),m.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{s.encodings[r]={...e,...t}})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();m.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:a}){this.assertNotClosed(),this.assertSendDirection();const n={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:a};m.debug("sendDataChannel() [options:%o]",n);const o=this._pc.createDataChannel(i,n);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%f.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),m.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:n.id,ordered:n.ordered,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const s of e){const{trackId:e,kind:t,rtpParameters:i,streamId:a}=s;m.debug("receive() [trackId:%s, kind:%s]",e,t);const n=i.mid||String(this._mapMidTransceiver.size);r.set(e,n),this._remoteSdp.receive({mid:n,kind:t,offerRtpParameters:i,streamId:a||i.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);for(const s of e){const{trackId:e,onRtpReceiver:t}=s;if(t){const s=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===s));if(!i)throw new Error("transceiver not found");t(i.receiver)}}let a=await this._pc.createAnswer();const n=s.parse(a.sdp);for(const s of e){const{trackId:e,rtpParameters:t}=s,i=r.get(e),a=n.media.find((e=>String(e.mid)===i));o.applyCodecParameters({offerRtpParameters:t,answerMediaObject:a})}a={type:"answer",sdp:s.write(n)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:n}),m.debug("receive() | calling pc.setLocalDescription() [answer:%o]",a),await this._pc.setLocalDescription(a);for(const s of e){const{trackId:e}=s,i=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===i));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,a),t.push({localId:i,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const s of e){m.debug("stopReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const s of e)this._mapMidTransceiver.delete(s)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){m.debug("pauseReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){m.debug("resumeReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o,protocol:r};m.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=o.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new p.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}};return he.Chrome111=g,he}(),l=function(){if(Ue)return qe;Ue=1;var e=qe&&qe.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=qe&&qe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=qe&&qe.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(qe,"__esModule",{value:!0}),qe.Chrome74=void 0;const s=r(ye()),i=_(),a=r(I()),n=r(B()),o=r(Se()),c=r(Ce()),d=r(De()),p=T(),l=xe(),h=je(),u=$e(),m=new i.Logger("Chrome74"),f={OS:1024,MIS:1024};let g=class e extends l.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome74"}close(){if(m.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){m.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const r=await e.createOffer();try{e.close()}catch(t){}const i=s.parse(r.sdp),a=o.extractRtpCapabilities({sdpObject:i});return d.addNackSuppportForOpus(a),a}catch(t){try{e.close()}catch(r){}throw t}}async getNativeSctpCapabilities(){return m.debug("getNativeSctpCapabilities()"),{numStreams:f}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:o,additionalSettings:c,proprietaryConstraints:d,extendedRtpCapabilities:p}){m.debug("run()"),this._direction=e,this._remoteSdp=new h.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i}),this._sendingRtpParametersByKind={audio:n.getSendingRtpParameters("audio",p),video:n.getSendingRtpParameters("video",p)},this._sendingRemoteRtpParametersByKind={audio:n.getSendingRemoteRtpParameters("audio",p),video:n.getSendingRemoteRtpParameters("video",p)},s.role&&"auto"!==s.role&&(this._forcedLocalDtlsRole="server"===s.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:o||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...c},d),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):(m.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})))}async updateIceServers(e){this.assertNotClosed(),m.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),m.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});m.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();m.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertNotClosed(),this.assertSendDirection(),m.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const d=a.clone(this._sendingRtpParametersByKind[e.kind]);d.codecs=n.reduceCodecs(d.codecs,i);const p=a.clone(this._sendingRemoteRtpParametersByKind[e.kind]);p.codecs=n.reduceCodecs(p.codecs,i);const l=this._remoteSdp.getNextMediaSectionIdx(),h=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});let f,g=await this._pc.createOffer(),b=s.parse(g.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:b});let _=!1;const y=(0,u.parse)((t||[{}])[0].scalabilityMode);t&&1===t.length&&y.spatialLayers>1&&"video/vp9"===d.codecs[0].mimeType.toLowerCase()&&(m.debug("send() | enabling legacy simulcast for VP9 SVC"),_=!0,b=s.parse(g.sdp),f=b.media[l.idx],c.addLegacySimulcast({offerMediaObject:f,numStreams:y.spatialLayers}),g={type:"offer",sdp:s.write(b)}),m.debug("send() | calling pc.setLocalDescription() [offer:%o]",g),await this._pc.setLocalDescription(g);const w=h.mid;if(d.mid=w,b=s.parse(this._pc.localDescription.sdp),f=b.media[l.idx],d.rtcp.cname=o.getCname({offerMediaObject:f}),t)if(1===t.length){let e=c.getRtpEncodings({offerMediaObject:f});Object.assign(e[0],t[0]),_&&(e=[e[0]]),d.encodings=e}else d.encodings=t;else d.encodings=c.getRtpEncodings({offerMediaObject:f});if(d.encodings.length>1&&("video/vp8"===d.codecs[0].mimeType.toLowerCase()||"video/h264"===d.codecs[0].mimeType.toLowerCase()))for(const s of d.encodings)s.scalabilityMode?s.scalabilityMode=`L1T${y.temporalLayers}`:s.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:f,reuseMid:l.reuseMid,offerRtpParameters:d,answerRtpParameters:p,codecOptions:r,extmapAllowMixed:!0});const v={type:"answer",sdp:this._remoteSdp.getSdp()};return m.debug("send() | calling pc.setRemoteDescription() [answer:%o]",v),await this._pc.setRemoteDescription(v),this._mapMidTransceiver.set(w,h),{localId:w,rtpParameters:d,rtpSender:h.sender}}async stopSending(e){if(this.assertSendDirection(),m.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");if(t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(i){}const r=await this._pc.createOffer();m.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),m.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();m.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),m.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();m.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?m.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):m.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),m.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();m.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),m.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{s.encodings[r]={...e,...t}})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();m.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:a}){this.assertNotClosed(),this.assertSendDirection();const n={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:a};m.debug("sendDataChannel() [options:%o]",n);const o=this._pc.createDataChannel(i,n);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%f.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),m.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:n.id,ordered:n.ordered,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const s of e){const{trackId:e,kind:t,rtpParameters:i,streamId:a}=s;m.debug("receive() [trackId:%s, kind:%s]",e,t);const n=i.mid||String(this._mapMidTransceiver.size);r.set(e,n),this._remoteSdp.receive({mid:n,kind:t,offerRtpParameters:i,streamId:a||i.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);let a=await this._pc.createAnswer();const n=s.parse(a.sdp);for(const s of e){const{trackId:e,rtpParameters:t}=s,i=r.get(e),a=n.media.find((e=>String(e.mid)===i));o.applyCodecParameters({offerRtpParameters:t,answerMediaObject:a})}a={type:"answer",sdp:s.write(n)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:n}),m.debug("receive() | calling pc.setLocalDescription() [answer:%o]",a),await this._pc.setLocalDescription(a);for(const s of e){const{trackId:e}=s,i=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===i));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,a),t.push({localId:i,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const s of e){m.debug("stopReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const s of e)this._mapMidTransceiver.delete(s)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){m.debug("pauseReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){m.debug("resumeReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o,protocol:r};m.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=o.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new p.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}};return qe.Chrome74=g,qe}(),u=function(){if(Ve)return We;Ve=1;var e=We&&We.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=We&&We.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=We&&We.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(We,"__esModule",{value:!0}),We.Chrome70=void 0;const s=r(ye()),i=_(),a=r(I()),n=r(B()),o=r(Se()),c=r(Ce()),d=xe(),p=je(),l=$e(),h=new i.Logger("Chrome70"),u={OS:1024,MIS:1024};let m=class e extends d.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome70"}close(){if(h.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){h.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const r=await e.createOffer();try{e.close()}catch(t){}const i=s.parse(r.sdp);return o.extractRtpCapabilities({sdpObject:i})}catch(t){try{e.close()}catch(r){}throw t}}async getNativeSctpCapabilities(){return h.debug("getNativeSctpCapabilities()"),{numStreams:u}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:o,additionalSettings:c,proprietaryConstraints:d,extendedRtpCapabilities:l}){h.debug("run()"),this._direction=e,this._remoteSdp=new p.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i}),this._sendingRtpParametersByKind={audio:n.getSendingRtpParameters("audio",l),video:n.getSendingRtpParameters("video",l)},this._sendingRemoteRtpParametersByKind={audio:n.getSendingRemoteRtpParameters("audio",l),video:n.getSendingRemoteRtpParameters("video",l)},s.role&&"auto"!==s.role&&(this._forcedLocalDtlsRole="server"===s.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:o||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...c},d),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(h.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){h.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(h.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});h.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();h.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertSendDirection(),h.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const d=a.clone(this._sendingRtpParametersByKind[e.kind]);d.codecs=n.reduceCodecs(d.codecs,i);const p=a.clone(this._sendingRemoteRtpParametersByKind[e.kind]);p.codecs=n.reduceCodecs(p.codecs,i);const u=this._remoteSdp.getNextMediaSectionIdx(),m=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});let f,g=await this._pc.createOffer(),b=s.parse(g.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:b}),t&&t.length>1&&(h.debug("send() | enabling legacy simulcast"),b=s.parse(g.sdp),f=b.media[u.idx],c.addLegacySimulcast({offerMediaObject:f,numStreams:t.length}),g={type:"offer",sdp:s.write(b)});let _=!1;const y=(0,l.parse)((t||[{}])[0].scalabilityMode);if(t&&1===t.length&&y.spatialLayers>1&&"video/vp9"===d.codecs[0].mimeType.toLowerCase()&&(h.debug("send() | enabling legacy simulcast for VP9 SVC"),_=!0,b=s.parse(g.sdp),f=b.media[u.idx],c.addLegacySimulcast({offerMediaObject:f,numStreams:y.spatialLayers}),g={type:"offer",sdp:s.write(b)}),h.debug("send() | calling pc.setLocalDescription() [offer:%o]",g),await this._pc.setLocalDescription(g),t){h.debug("send() | applying given encodings");const e=m.sender.getParameters();for(let r=0;r<(e.encodings||[]).length;++r){const s=e.encodings[r],i=t[r];if(!i)break;e.encodings[r]=Object.assign(s,i)}await m.sender.setParameters(e)}const w=m.mid;if(d.mid=w,b=s.parse(this._pc.localDescription.sdp),f=b.media[u.idx],d.rtcp.cname=o.getCname({offerMediaObject:f}),d.encodings=c.getRtpEncodings({offerMediaObject:f}),t)for(let s=0;s<d.encodings.length;++s)t[s]&&Object.assign(d.encodings[s],t[s]);if(_&&(d.encodings=[d.encodings[0]]),d.encodings.length>1&&("video/vp8"===d.codecs[0].mimeType.toLowerCase()||"video/h264"===d.codecs[0].mimeType.toLowerCase()))for(const s of d.encodings)s.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:f,reuseMid:u.reuseMid,offerRtpParameters:d,answerRtpParameters:p,codecOptions:r});const v={type:"answer",sdp:this._remoteSdp.getSdp()};return h.debug("send() | calling pc.setRemoteDescription() [answer:%o]",v),await this._pc.setRemoteDescription(v),this._mapMidTransceiver.set(w,m),{localId:w,rtpParameters:d,rtpSender:m.sender}}async stopSending(e){this.assertSendDirection(),h.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");if(t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(i){}const r=await this._pc.createOffer();h.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s),this._mapMidTransceiver.delete(e)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?h.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):h.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),h.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();h.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),h.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{s.encodings[r]={...e,...t}})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();h.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:a}){this.assertSendDirection();const n={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:a};h.debug("sendDataChannel() [options:%o]",n);const o=this._pc.createDataChannel(i,n);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%u.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),h.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:n.id,ordered:n.ordered,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[],r=new Map;for(const s of e){const{trackId:e,kind:t,rtpParameters:i,streamId:a}=s;h.debug("receive() [trackId:%s, kind:%s]",e,t);const n=i.mid||String(this._mapMidTransceiver.size);r.set(e,n),this._remoteSdp.receive({mid:n,kind:t,offerRtpParameters:i,streamId:a||i.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);let a=await this._pc.createAnswer();const n=s.parse(a.sdp);for(const s of e){const{trackId:e,rtpParameters:t}=s,i=r.get(e),a=n.media.find((e=>String(e.mid)===i));o.applyCodecParameters({offerRtpParameters:t,answerMediaObject:a})}a={type:"answer",sdp:s.write(n)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:n}),h.debug("receive() | calling pc.setLocalDescription() [answer:%o]",a),await this._pc.setLocalDescription(a);for(const s of e){const{trackId:e}=s,i=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===i));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,a),t.push({localId:i,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){this.assertRecvDirection();for(const s of e){h.debug("stopReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();h.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const s of e)this._mapMidTransceiver.delete(s)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:a,maxPacketLifeTime:n,maxRetransmitTime:n,maxRetransmits:o,protocol:r};h.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}h.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=o.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}};return We.Chrome70=m,We}(),m=function(){if(He)return Ge;He=1;var e=Ge&&Ge.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=Ge&&Ge.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=Ge&&Ge.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.Chrome67=void 0;const s=r(ye()),i=_(),a=r(I()),n=r(B()),o=r(Se()),c=r(Je()),d=xe(),p=je(),l=new i.Logger("Chrome67"),h={OS:1024,MIS:1024};let u=class e extends d.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdRtpSender=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome67"}close(){if(l.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){l.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const r=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(t){}const i=s.parse(r.sdp);return o.extractRtpCapabilities({sdpObject:i})}catch(t){try{e.close()}catch(r){}throw t}}async getNativeSctpCapabilities(){return l.debug("getNativeSctpCapabilities()"),{numStreams:h}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:o,additionalSettings:c,proprietaryConstraints:d,extendedRtpCapabilities:h}){l.debug("run()"),this._direction=e,this._remoteSdp=new p.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:n.getSendingRtpParameters("audio",h),video:n.getSendingRtpParameters("video",h)},this._sendingRemoteRtpParametersByKind={audio:n.getSendingRemoteRtpParameters("audio",h),video:n.getSendingRemoteRtpParameters("video",h)},s.role&&"auto"!==s.role&&(this._forcedLocalDtlsRole="server"===s.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:o||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...c},d),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(l.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){l.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(l.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});l.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};l.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};l.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();l.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertSendDirection(),l.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),i&&l.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addTrack(e,this._sendStream);let d,p=await this._pc.createOffer(),h=s.parse(p.sdp);const u=a.clone(this._sendingRtpParametersByKind[e.kind]);u.codecs=n.reduceCodecs(u.codecs);const m=a.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(m.codecs=n.reduceCodecs(m.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:h}),"video"===e.kind&&t&&t.length>1&&(l.debug("send() | enabling simulcast"),h=s.parse(p.sdp),d=h.media.find((e=>"video"===e.type)),c.addLegacySimulcast({offerMediaObject:d,track:e,numStreams:t.length}),p={type:"offer",sdp:s.write(h)}),l.debug("send() | calling pc.setLocalDescription() [offer:%o]",p),await this._pc.setLocalDescription(p),h=s.parse(this._pc.localDescription.sdp),d=h.media.find((t=>t.type===e.kind)),u.rtcp.cname=o.getCname({offerMediaObject:d}),u.encodings=c.getRtpEncodings({offerMediaObject:d,track:e}),t)for(let s=0;s<u.encodings.length;++s)t[s]&&Object.assign(u.encodings[s],t[s]);if(u.encodings.length>1&&"video/vp8"===u.codecs[0].mimeType.toLowerCase())for(const s of u.encodings)s.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:d,offerRtpParameters:u,answerRtpParameters:m,codecOptions:r});const f={type:"answer",sdp:this._remoteSdp.getSdp()};l.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f);const g=String(this._nextSendLocalId);this._nextSendLocalId++;const b=this._pc.getSenders().find((t=>t.track===e));return this._mapSendLocalIdRtpSender.set(g,b),{localId:g,rtpParameters:u,rtpSender:b}}async stopSending(e){this.assertSendDirection(),l.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");this._pc.removeTrack(t),t.track&&this._sendStream.removeTrack(t.track),this._mapSendLocalIdRtpSender.delete(e);const r=await this._pc.createOffer();l.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(i){if(0===this._sendStream.getTracks().length)return void l.warn("stopSending() | ignoring expected error due no sending tracks: %s",i.toString());throw i}if("stable"===this._pc.signalingState)return;const s={type:"answer",sdp:this._remoteSdp.getSdp()};l.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?l.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):l.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const s=r.track;await r.replaceTrack(t),s&&this._sendStream.removeTrack(s),t&&this._sendStream.addTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),l.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const s=r.getParameters();s.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(s)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),l.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const s=r.getParameters();s.encodings.forEach(((e,r)=>{s.encodings[r]={...e,...t}})),await r.setParameters(s)}async getSenderStats(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");return t.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:a}){this.assertSendDirection();const n={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:a};l.debug("sendDataChannel() [options:%o]",n);const o=this._pc.createDataChannel(i,n);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%h.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),l.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};l.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:n.id,ordered:n.ordered,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const s of e){const{trackId:e,kind:t,rtpParameters:r,streamId:i}=s;l.debug("receive() [trackId:%s, kind:%s]",e,t);const a=t;this._remoteSdp.receive({mid:a,kind:t,offerRtpParameters:r,streamId:i||r.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};l.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let i=await this._pc.createAnswer();const a=s.parse(i.sdp);for(const s of e){const{kind:e,rtpParameters:t}=s,r=e,i=a.media.find((e=>String(e.mid)===r));o.applyCodecParameters({offerRtpParameters:t,answerMediaObject:i})}i={type:"answer",sdp:s.write(a)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a}),l.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const s of e){const{kind:e,trackId:r,rtpParameters:i}=s,a=r,n=e,o=this._pc.getReceivers().find((e=>e.track&&e.track.id===a));if(!o)throw new Error("new RTCRtpReceiver not");this._mapRecvLocalIdInfo.set(a,{mid:n,rtpParameters:i,rtpReceiver:o}),t.push({localId:a,track:o.track,rtpReceiver:o})}return t}async stopReceiving(e){this.assertRecvDirection();for(const s of e){l.debug("stopReceiving() [localId:%s]",s);const{mid:e,rtpParameters:t}=this._mapRecvLocalIdInfo.get(s)||{};this._mapRecvLocalIdInfo.delete(s),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:t})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};l.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();l.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){this.assertRecvDirection();const{rtpReceiver:t}=this._mapRecvLocalIdInfo.get(e)||{};if(!t)throw new Error("associated RTCRtpReceiver not found");return t.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:a,maxPacketLifeTime:n,maxRetransmitTime:n,maxRetransmits:o,protocol:r};l.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};l.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}l.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=o.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}};return Ge.Chrome67=u,Ge}(),g=function(){if(Qe)return Xe;Qe=1;var e=Xe&&Xe.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=Xe&&Xe.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=Xe&&Xe.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.Chrome55=void 0;const s=r(ye()),i=_(),a=T(),n=r(I()),o=r(B()),c=r(Se()),d=r(Je()),p=xe(),l=je(),h=new i.Logger("Chrome55"),u={OS:1024,MIS:1024};let m=class e extends p.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdTrack=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome55"}close(){if(h.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){h.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const r=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(t){}const i=s.parse(r.sdp);return c.extractRtpCapabilities({sdpObject:i})}catch(t){try{e.close()}catch(r){}throw t}}async getNativeSctpCapabilities(){return h.debug("getNativeSctpCapabilities()"),{numStreams:u}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:n,additionalSettings:c,proprietaryConstraints:d,extendedRtpCapabilities:p}){h.debug("run()"),this._direction=e,this._remoteSdp=new l.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:o.getSendingRtpParameters("audio",p),video:o.getSendingRtpParameters("video",p)},this._sendingRemoteRtpParametersByKind={audio:o.getSendingRemoteRtpParameters("audio",p),video:o.getSendingRemoteRtpParameters("video",p)},s.role&&"auto"!==s.role&&(this._forcedLocalDtlsRole="server"===s.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:n||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...c},d),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(h.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){h.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(h.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});h.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();h.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertSendDirection(),h.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),i&&h.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addStream(this._sendStream);let a,p=await this._pc.createOffer(),l=s.parse(p.sdp);const u=n.clone(this._sendingRtpParametersByKind[e.kind]);u.codecs=o.reduceCodecs(u.codecs);const m=n.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(m.codecs=o.reduceCodecs(m.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l}),"video"===e.kind&&t&&t.length>1&&(h.debug("send() | enabling simulcast"),l=s.parse(p.sdp),a=l.media.find((e=>"video"===e.type)),d.addLegacySimulcast({offerMediaObject:a,track:e,numStreams:t.length}),p={type:"offer",sdp:s.write(l)}),h.debug("send() | calling pc.setLocalDescription() [offer:%o]",p),await this._pc.setLocalDescription(p),l=s.parse(this._pc.localDescription.sdp),a=l.media.find((t=>t.type===e.kind)),u.rtcp.cname=c.getCname({offerMediaObject:a}),u.encodings=d.getRtpEncodings({offerMediaObject:a,track:e}),t)for(let s=0;s<u.encodings.length;++s)t[s]&&Object.assign(u.encodings[s],t[s]);if(u.encodings.length>1&&"video/vp8"===u.codecs[0].mimeType.toLowerCase())for(const s of u.encodings)s.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:a,offerRtpParameters:u,answerRtpParameters:m,codecOptions:r});const f={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f);const g=String(this._nextSendLocalId);return this._nextSendLocalId++,this._mapSendLocalIdTrack.set(g,e),{localId:g,rtpParameters:u}}async stopSending(e){this.assertSendDirection(),h.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdTrack.get(e);if(!t)throw new Error("track not found");this._mapSendLocalIdTrack.delete(e),this._sendStream.removeTrack(t),this._pc.addStream(this._sendStream);const r=await this._pc.createOffer();h.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(i){if(0===this._sendStream.getTracks().length)return void h.warn("stopSending() | ignoring expected error due no sending tracks: %s",i.toString());throw i}if("stable"===this._pc.signalingState)return;const s={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){throw new a.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new a.UnsupportedError(" not implemented")}async setRtpEncodingParameters(e,t){throw new a.UnsupportedError("not supported")}async getSenderStats(e){throw new a.UnsupportedError("not implemented")}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:a}){this.assertSendDirection();const n={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:a};h.debug("sendDataChannel() [options:%o]",n);const o=this._pc.createDataChannel(i,n);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%u.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),h.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:n.id,ordered:n.ordered,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const s of e){const{trackId:e,kind:t,rtpParameters:r,streamId:i}=s;h.debug("receive() [trackId:%s, kind:%s]",e,t);const a=t;this._remoteSdp.receive({mid:a,kind:t,offerRtpParameters:r,streamId:i||r.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let i=await this._pc.createAnswer();const a=s.parse(i.sdp);for(const s of e){const{kind:e,rtpParameters:t}=s,r=e,i=a.media.find((e=>String(e.mid)===r));c.applyCodecParameters({offerRtpParameters:t,answerMediaObject:i})}i={type:"answer",sdp:s.write(a)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a}),h.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const s of e){const{kind:e,trackId:r,rtpParameters:i}=s,a=e,n=r,o=s.streamId||i.rtcp.cname,c=this._pc.getRemoteStreams().find((e=>e.id===o)).getTrackById(n);if(!c)throw new Error("remote track not found");this._mapRecvLocalIdInfo.set(n,{mid:a,rtpParameters:i}),t.push({localId:n,track:c})}return t}async stopReceiving(e){this.assertRecvDirection();for(const s of e){h.debug("stopReceiving() [localId:%s]",s);const{mid:e,rtpParameters:t}=this._mapRecvLocalIdInfo.get(s)||{};this._mapRecvLocalIdInfo.delete(s),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:t})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();h.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new a.UnsupportedError("not implemented")}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:a,maxPacketLifeTime:n,maxRetransmitTime:n,maxRetransmits:o,protocol:r};h.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}h.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=c.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}};return Xe.Chrome55=m,Xe}(),b=function(){if(Ye)return Ze;Ye=1;var e=Ze&&Ze.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=Ze&&Ze.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=Ze&&Ze.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.Firefox120=void 0;const s=r(ye()),i=_(),a=T(),n=r(I()),o=r(B()),c=r(Se()),d=r(Ce()),p=xe(),l=je(),h=$e(),u=new i.Logger("Firefox120"),m={OS:16,MIS:2048};let f=class e extends p.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Firefox120"}close(){if(u.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){u.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"}),t=document.createElement("canvas");t.getContext("2d");const r=t.captureStream().getVideoTracks()[0];try{e.addTransceiver("audio",{direction:"sendrecv"}),e.addTransceiver(r,{direction:"sendrecv",sendEncodings:[{rid:"r0",maxBitrate:1e5},{rid:"r1",maxBitrate:5e5}]});const a=await e.createOffer();try{t.remove()}catch(i){}try{r.stop()}catch(i){}try{e.close()}catch(i){}const n=s.parse(a.sdp);return c.extractRtpCapabilities({sdpObject:n})}catch(i){try{t.remove()}catch(a){}try{r.stop()}catch(a){}try{e.close()}catch(a){}throw i}}async getNativeSctpCapabilities(){return u.debug("getNativeSctpCapabilities()"),{numStreams:m}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:n,additionalSettings:c,proprietaryConstraints:d,extendedRtpCapabilities:p}){this.assertNotClosed(),u.debug("run()"),this._direction=e,this._remoteSdp=new l.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i}),this._sendingRtpParametersByKind={audio:o.getSendingRtpParameters("audio",p),video:o.getSendingRtpParameters("video",p)},this._sendingRemoteRtpParametersByKind={audio:o.getSendingRemoteRtpParameters("audio",p),video:o.getSendingRemoteRtpParameters("video",p)},this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:n||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...c},d),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(u.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){throw this.assertNotClosed(),new a.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),u.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});u.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();u.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i,onRtpSender:a}){this.assertNotClosed(),this.assertSendDirection(),u.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const p=n.clone(this._sendingRtpParametersByKind[e.kind]);p.codecs=o.reduceCodecs(p.codecs,i);const l=n.clone(this._sendingRemoteRtpParametersByKind[e.kind]);l.codecs=o.reduceCodecs(l.codecs,i);const m=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});a&&a(m.sender);const f=await this._pc.createOffer();let g=s.parse(f.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:g});const b=(0,h.parse)((t||[{}])[0].scalabilityMode);u.debug("send() | calling pc.setLocalDescription() [offer:%o]",f),await this._pc.setLocalDescription(f);const _=m.mid;p.mid=_,g=s.parse(this._pc.localDescription.sdp);const y=g.media[g.media.length-1];if(p.rtcp.cname=c.getCname({offerMediaObject:y}),t)if(1===t.length){const e=d.getRtpEncodings({offerMediaObject:y});Object.assign(e[0],t[0]),p.encodings=e}else p.encodings=t;else p.encodings=d.getRtpEncodings({offerMediaObject:y});if(p.encodings.length>1&&("video/vp8"===p.codecs[0].mimeType.toLowerCase()||"video/h264"===p.codecs[0].mimeType.toLowerCase()))for(const s of p.encodings)s.scalabilityMode?s.scalabilityMode=`L1T${b.temporalLayers}`:s.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:y,offerRtpParameters:p,answerRtpParameters:l,codecOptions:r,extmapAllowMixed:!0});const w={type:"answer",sdp:this._remoteSdp.getSdp()};return u.debug("send() | calling pc.setRemoteDescription() [answer:%o]",w),await this._pc.setRemoteDescription(w),this._mapMidTransceiver.set(_,m),{localId:_,rtpParameters:p,rtpSender:m.sender}}async stopSending(e){if(this.assertSendDirection(),u.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated transceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.disableMediaSection(t.mid);const r=await this._pc.createOffer();u.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),u.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();u.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),u.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();u.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?u.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):u.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),u.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated transceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();u.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),u.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{s.encodings[r]={...e,...t}})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();u.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:a}){this.assertNotClosed(),this.assertSendDirection();const n={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:a};u.debug("sendDataChannel() [options:%o]",n);const o=this._pc.createDataChannel(i,n);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%m.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),u.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:n.id,ordered:n.ordered,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const s of e){const{trackId:e,kind:t,rtpParameters:i,streamId:a}=s;u.debug("receive() [trackId:%s, kind:%s]",e,t);const n=i.mid||String(this._mapMidTransceiver.size);r.set(e,n),this._remoteSdp.receive({mid:n,kind:t,offerRtpParameters:i,streamId:a||i.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);for(const s of e){const{trackId:e,onRtpReceiver:t}=s;if(t){const s=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===s));if(!i)throw new Error("transceiver not found");t(i.receiver)}}let a=await this._pc.createAnswer();const n=s.parse(a.sdp);for(const o of e){const{trackId:e,rtpParameters:t}=o,i=r.get(e),d=n.media.find((e=>String(e.mid)===i));c.applyCodecParameters({offerRtpParameters:t,answerMediaObject:d}),a={type:"answer",sdp:s.write(n)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:n}),u.debug("receive() | calling pc.setLocalDescription() [answer:%o]",a),await this._pc.setLocalDescription(a);for(const s of e){const{trackId:e}=s,i=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===i));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,a),t.push({localId:i,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const s of e){u.debug("stopReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();u.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const s of e)this._mapMidTransceiver.delete(s)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){u.debug("pauseReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();u.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){u.debug("resumeReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();u.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o,protocol:r};u.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}u.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=c.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new a.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}};return Ze.Firefox120=f,Ze}(),y=function(){if(et)return tt;et=1;var e=tt&&tt.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=tt&&tt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=tt&&tt.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(tt,"__esModule",{value:!0}),tt.Firefox60=void 0;const s=r(ye()),i=_(),a=T(),n=r(I()),o=r(B()),c=r(Se()),d=r(Ce()),p=xe(),l=je(),h=$e(),u=new i.Logger("Firefox60"),m={OS:16,MIS:2048};let f=class e extends p.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Firefox60"}close(){if(u.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){u.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"}),t=document.createElement("canvas");t.getContext("2d");const r=t.captureStream().getVideoTracks()[0];try{e.addTransceiver("audio",{direction:"sendrecv"});const a=e.addTransceiver(r,{direction:"sendrecv"}),n=a.sender.getParameters(),o=[{rid:"r0",maxBitrate:1e5},{rid:"r1",maxBitrate:5e5}];n.encodings=o,await a.sender.setParameters(n);const d=await e.createOffer();try{t.remove()}catch(i){}try{r.stop()}catch(i){}try{e.close()}catch(i){}const p=s.parse(d.sdp);return c.extractRtpCapabilities({sdpObject:p})}catch(i){try{t.remove()}catch(a){}try{r.stop()}catch(a){}try{e.close()}catch(a){}throw i}}async getNativeSctpCapabilities(){return u.debug("getNativeSctpCapabilities()"),{numStreams:m}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:n,additionalSettings:c,proprietaryConstraints:d,extendedRtpCapabilities:p}){this.assertNotClosed(),u.debug("run()"),this._direction=e,this._remoteSdp=new l.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i}),this._sendingRtpParametersByKind={audio:o.getSendingRtpParameters("audio",p),video:o.getSendingRtpParameters("video",p)},this._sendingRemoteRtpParametersByKind={audio:o.getSendingRemoteRtpParameters("audio",p),video:o.getSendingRemoteRtpParameters("video",p)},this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:n||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...c},d),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(u.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){throw this.assertNotClosed(),new a.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),u.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});u.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();u.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertNotClosed(),this.assertSendDirection(),u.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&(t=n.clone(t)).length>1&&(t.forEach(((e,t)=>{e.rid=`r${t}`})),t.reverse());const a=n.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=o.reduceCodecs(a.codecs,i);const p=n.clone(this._sendingRemoteRtpParametersByKind[e.kind]);p.codecs=o.reduceCodecs(p.codecs,i);const l=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});if(t){const e=l.sender.getParameters();e.encodings=t,await l.sender.setParameters(e)}const m=await this._pc.createOffer();let f=s.parse(m.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:f});const g=(0,h.parse)((t||[{}])[0].scalabilityMode);u.debug("send() | calling pc.setLocalDescription() [offer:%o]",m),await this._pc.setLocalDescription(m);const b=l.mid;a.mid=b,f=s.parse(this._pc.localDescription.sdp);const _=f.media[f.media.length-1];if(a.rtcp.cname=c.getCname({offerMediaObject:_}),t)if(1===t.length){const e=d.getRtpEncodings({offerMediaObject:_});Object.assign(e[0],t[0]),a.encodings=e}else a.encodings=t.reverse();else a.encodings=d.getRtpEncodings({offerMediaObject:_});if(a.encodings.length>1&&("video/vp8"===a.codecs[0].mimeType.toLowerCase()||"video/h264"===a.codecs[0].mimeType.toLowerCase()))for(const s of a.encodings)s.scalabilityMode?s.scalabilityMode=`L1T${g.temporalLayers}`:s.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:_,offerRtpParameters:a,answerRtpParameters:p,codecOptions:r,extmapAllowMixed:!0});const y={type:"answer",sdp:this._remoteSdp.getSdp()};return u.debug("send() | calling pc.setRemoteDescription() [answer:%o]",y),await this._pc.setRemoteDescription(y),this._mapMidTransceiver.set(b,l),{localId:b,rtpParameters:a,rtpSender:l.sender}}async stopSending(e){if(this.assertSendDirection(),u.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated transceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.disableMediaSection(t.mid);const r=await this._pc.createOffer();u.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),u.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();u.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),u.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();u.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?u.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):u.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),u.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated transceiver not found");const s=r.sender.getParameters();t=s.encodings.length-1-t,s.encodings.forEach(((e,r)=>{e.active=r>=t})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();u.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),u.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{s.encodings[r]={...e,...t}})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();u.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:a}){this.assertNotClosed(),this.assertSendDirection();const n={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:a};u.debug("sendDataChannel() [options:%o]",n);const o=this._pc.createDataChannel(i,n);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%m.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),u.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};u.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:n.id,ordered:n.ordered,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const s of e){const{trackId:e,kind:t,rtpParameters:i,streamId:a}=s;u.debug("receive() [trackId:%s, kind:%s]",e,t);const n=i.mid||String(this._mapMidTransceiver.size);r.set(e,n),this._remoteSdp.receive({mid:n,kind:t,offerRtpParameters:i,streamId:a||i.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);let a=await this._pc.createAnswer();const n=s.parse(a.sdp);for(const o of e){const{trackId:e,rtpParameters:t}=o,i=r.get(e),d=n.media.find((e=>String(e.mid)===i));c.applyCodecParameters({offerRtpParameters:t,answerMediaObject:d}),a={type:"answer",sdp:s.write(n)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:n}),u.debug("receive() | calling pc.setLocalDescription() [answer:%o]",a),await this._pc.setLocalDescription(a);for(const s of e){const{trackId:e}=s,i=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===i));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,a),t.push({localId:i,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const s of e){u.debug("stopReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();u.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const s of e)this._mapMidTransceiver.delete(s)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){u.debug("pauseReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();u.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){u.debug("resumeReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();u.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o,protocol:r};u.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};u.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}u.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=c.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new a.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}};return tt.Firefox60=f,tt}(),w=function(){if(rt)return st;rt=1;var e=st&&st.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=st&&st.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=st&&st.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(st,"__esModule",{value:!0}),st.Safari12=void 0;const s=r(ye()),i=_(),a=r(I()),n=r(B()),o=r(Se()),c=r(Ce()),d=r(De()),p=T(),l=xe(),h=je(),u=$e(),m=new i.Logger("Safari12"),f={OS:1024,MIS:1024};let g=class e extends l.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Safari12"}close(){if(m.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){m.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});try{e.addTransceiver("audio"),e.addTransceiver("video");const r=await e.createOffer();try{e.close()}catch(t){}const i=s.parse(r.sdp),a=o.extractRtpCapabilities({sdpObject:i});return d.addNackSuppportForOpus(a),a}catch(t){try{e.close()}catch(r){}throw t}}async getNativeSctpCapabilities(){return m.debug("getNativeSctpCapabilities()"),{numStreams:f}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:o,additionalSettings:c,proprietaryConstraints:d,extendedRtpCapabilities:p}){this.assertNotClosed(),m.debug("run()"),this._direction=e,this._remoteSdp=new h.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i}),this._sendingRtpParametersByKind={audio:n.getSendingRtpParameters("audio",p),video:n.getSendingRtpParameters("video",p)},this._sendingRemoteRtpParametersByKind={audio:n.getSendingRemoteRtpParameters("audio",p),video:n.getSendingRemoteRtpParameters("video",p)},s.role&&"auto"!==s.role&&(this._forcedLocalDtlsRole="server"===s.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:o||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...c},d),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(m.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){this.assertNotClosed(),m.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),m.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});m.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();m.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i,onRtpSender:d}){this.assertNotClosed(),this.assertSendDirection(),m.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const p=a.clone(this._sendingRtpParametersByKind[e.kind]);p.codecs=n.reduceCodecs(p.codecs,i);const l=a.clone(this._sendingRemoteRtpParametersByKind[e.kind]);l.codecs=n.reduceCodecs(l.codecs,i);const h=this._remoteSdp.getNextMediaSectionIdx(),f=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});d&&d(f.sender);let g,b=await this._pc.createOffer(),_=s.parse(b.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:_});const y=(0,u.parse)((t||[{}])[0].scalabilityMode);t&&t.length>1&&(m.debug("send() | enabling legacy simulcast"),_=s.parse(b.sdp),g=_.media[h.idx],c.addLegacySimulcast({offerMediaObject:g,numStreams:t.length}),b={type:"offer",sdp:s.write(_)}),m.debug("send() | calling pc.setLocalDescription() [offer:%o]",b),await this._pc.setLocalDescription(b);const w=f.mid;if(p.mid=w,_=s.parse(this._pc.localDescription.sdp),g=_.media[h.idx],p.rtcp.cname=o.getCname({offerMediaObject:g}),p.encodings=c.getRtpEncodings({offerMediaObject:g}),t)for(let s=0;s<p.encodings.length;++s)t[s]&&Object.assign(p.encodings[s],t[s]);if(p.encodings.length>1&&("video/vp8"===p.codecs[0].mimeType.toLowerCase()||"video/h264"===p.codecs[0].mimeType.toLowerCase()))for(const s of p.encodings)s.scalabilityMode?s.scalabilityMode=`L1T${y.temporalLayers}`:s.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:g,reuseMid:h.reuseMid,offerRtpParameters:p,answerRtpParameters:l,codecOptions:r});const v={type:"answer",sdp:this._remoteSdp.getSdp()};return m.debug("send() | calling pc.setRemoteDescription() [answer:%o]",v),await this._pc.setRemoteDescription(v),this._mapMidTransceiver.set(w,f),{localId:w,rtpParameters:p,rtpSender:f.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;m.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");if(t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(i){}const r=await this._pc.createOffer();m.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),m.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();m.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),m.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();m.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?m.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):m.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),m.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();m.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),m.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{s.encodings[r]={...e,...t}})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();m.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:a}){this.assertNotClosed(),this.assertSendDirection();const n={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:a};m.debug("sendDataChannel() [options:%o]",n);const o=this._pc.createDataChannel(i,n);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%f.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),m.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:n.id,ordered:n.ordered,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const s of e){const{trackId:e,kind:t,rtpParameters:i,streamId:a}=s;m.debug("receive() [trackId:%s, kind:%s]",e,t);const n=i.mid||String(this._mapMidTransceiver.size);r.set(e,n),this._remoteSdp.receive({mid:n,kind:t,offerRtpParameters:i,streamId:a||i.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);for(const s of e){const{trackId:e,onRtpReceiver:t}=s;if(t){const s=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===s));if(!i)throw new Error("transceiver not found");t(i.receiver)}}let a=await this._pc.createAnswer();const n=s.parse(a.sdp);for(const s of e){const{trackId:e,rtpParameters:t}=s,i=r.get(e),a=n.media.find((e=>String(e.mid)===i));o.applyCodecParameters({offerRtpParameters:t,answerMediaObject:a})}a={type:"answer",sdp:s.write(n)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:n}),m.debug("receive() | calling pc.setLocalDescription() [answer:%o]",a),await this._pc.setLocalDescription(a);for(const s of e){const{trackId:e}=s,i=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===i));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,a),t.push({localId:i,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const s of e){m.debug("stopReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const s of e)this._mapMidTransceiver.delete(s)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){m.debug("pauseReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){m.debug("resumeReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o,protocol:r};m.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=o.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new p.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}};return st.Safari12=g,st}(),v=function(){if(it)return at;it=1;var e=at&&at.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=at&&at.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=at&&at.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(at,"__esModule",{value:!0}),at.Safari11=void 0;const s=r(ye()),i=_(),a=r(I()),n=r(B()),o=r(Se()),c=r(Je()),d=xe(),p=je(),l=new i.Logger("Safari11"),h={OS:1024,MIS:1024};let u=class e extends d.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdRtpSender=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Safari11"}close(){if(l.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){l.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const r=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(t){}const i=s.parse(r.sdp);return o.extractRtpCapabilities({sdpObject:i})}catch(t){try{e.close()}catch(r){}throw t}}async getNativeSctpCapabilities(){return l.debug("getNativeSctpCapabilities()"),{numStreams:h}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:o,additionalSettings:c,proprietaryConstraints:d,extendedRtpCapabilities:h}){l.debug("run()"),this._direction=e,this._remoteSdp=new p.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:n.getSendingRtpParameters("audio",h),video:n.getSendingRtpParameters("video",h)},this._sendingRemoteRtpParametersByKind={audio:n.getSendingRemoteRtpParameters("audio",h),video:n.getSendingRemoteRtpParameters("video",h)},s.role&&"auto"!==s.role&&(this._forcedLocalDtlsRole="server"===s.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:o||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...c},d),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(l.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){l.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(l.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});l.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};l.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};l.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();l.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertSendDirection(),l.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),i&&l.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addTrack(e,this._sendStream);let d,p=await this._pc.createOffer(),h=s.parse(p.sdp);const u=a.clone(this._sendingRtpParametersByKind[e.kind]);u.codecs=n.reduceCodecs(u.codecs);const m=a.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(m.codecs=n.reduceCodecs(m.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:h}),"video"===e.kind&&t&&t.length>1&&(l.debug("send() | enabling simulcast"),h=s.parse(p.sdp),d=h.media.find((e=>"video"===e.type)),c.addLegacySimulcast({offerMediaObject:d,track:e,numStreams:t.length}),p={type:"offer",sdp:s.write(h)}),l.debug("send() | calling pc.setLocalDescription() [offer:%o]",p),await this._pc.setLocalDescription(p),h=s.parse(this._pc.localDescription.sdp),d=h.media.find((t=>t.type===e.kind)),u.rtcp.cname=o.getCname({offerMediaObject:d}),u.encodings=c.getRtpEncodings({offerMediaObject:d,track:e}),t)for(let s=0;s<u.encodings.length;++s)t[s]&&Object.assign(u.encodings[s],t[s]);if(u.encodings.length>1&&"video/vp8"===u.codecs[0].mimeType.toLowerCase())for(const s of u.encodings)s.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:d,offerRtpParameters:u,answerRtpParameters:m,codecOptions:r});const f={type:"answer",sdp:this._remoteSdp.getSdp()};l.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f);const g=String(this._nextSendLocalId);this._nextSendLocalId++;const b=this._pc.getSenders().find((t=>t.track===e));return this._mapSendLocalIdRtpSender.set(g,b),{localId:g,rtpParameters:u,rtpSender:b}}async stopSending(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");t.track&&this._sendStream.removeTrack(t.track),this._mapSendLocalIdRtpSender.delete(e);const r=await this._pc.createOffer();l.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(i){if(0===this._sendStream.getTracks().length)return void l.warn("stopSending() | ignoring expected error due no sending tracks: %s",i.toString());throw i}if("stable"===this._pc.signalingState)return;const s={type:"answer",sdp:this._remoteSdp.getSdp()};l.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?l.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):l.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const s=r.track;await r.replaceTrack(t),s&&this._sendStream.removeTrack(s),t&&this._sendStream.addTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),l.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const s=r.getParameters();s.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(s)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),l.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const s=r.getParameters();s.encodings.forEach(((e,r)=>{s.encodings[r]={...e,...t}})),await r.setParameters(s)}async getSenderStats(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");return t.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:a}){this.assertSendDirection();const n={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:a};l.debug("sendDataChannel() [options:%o]",n);const o=this._pc.createDataChannel(i,n);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%h.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),l.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};l.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:n.id,ordered:n.ordered,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const s of e){const{trackId:e,kind:t,rtpParameters:r,streamId:i}=s;l.debug("receive() [trackId:%s, kind:%s]",e,t);const a=t;this._remoteSdp.receive({mid:a,kind:t,offerRtpParameters:r,streamId:i||r.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};l.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let i=await this._pc.createAnswer();const a=s.parse(i.sdp);for(const s of e){const{kind:e,rtpParameters:t}=s,r=e,i=a.media.find((e=>String(e.mid)===r));o.applyCodecParameters({offerRtpParameters:t,answerMediaObject:i})}i={type:"answer",sdp:s.write(a)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a}),l.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const s of e){const{kind:e,trackId:r,rtpParameters:i}=s,a=e,n=r,o=this._pc.getReceivers().find((e=>e.track&&e.track.id===n));if(!o)throw new Error("new RTCRtpReceiver not");this._mapRecvLocalIdInfo.set(n,{mid:a,rtpParameters:i,rtpReceiver:o}),t.push({localId:n,track:o.track,rtpReceiver:o})}return t}async stopReceiving(e){this.assertRecvDirection();for(const s of e){l.debug("stopReceiving() [localId:%s]",s);const{mid:e,rtpParameters:t}=this._mapRecvLocalIdInfo.get(s)||{};this._mapRecvLocalIdInfo.delete(s),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:t})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};l.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();l.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const{rtpReceiver:t}=this._mapRecvLocalIdInfo.get(e)||{};if(!t)throw new Error("associated RTCRtpReceiver not found");return t.getStats()}async pauseReceiving(e){}async resumeReceiving(e){}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o,protocol:r};l.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};l.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}l.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=o.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}};return at.Safari11=u,at}(),S=pt(),R=function(){if(lt)return ht;lt=1;var e=ht&&ht.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=ht&&ht.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=ht&&ht.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(ht,"__esModule",{value:!0}),ht.ReactNativeUnifiedPlan=void 0;const s=r(ye()),i=_(),a=r(I()),n=r(B()),o=r(Se()),c=r(Ce()),d=r(De()),p=T(),l=xe(),h=je(),u=$e(),m=new i.Logger("ReactNativeUnifiedPlan"),f={OS:1024,MIS:1024};let g=class e extends l.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"ReactNativeUnifiedPlan"}close(){if(m.debug("close()"),!this._closed){if(this._closed=!0,this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){m.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const r=await e.createOffer();try{e.close()}catch(t){}const i=s.parse(r.sdp),a=o.extractRtpCapabilities({sdpObject:i});return d.addNackSuppportForOpus(a),a}catch(t){try{e.close()}catch(r){}throw t}}async getNativeSctpCapabilities(){return m.debug("getNativeSctpCapabilities()"),{numStreams:f}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:o,additionalSettings:c,proprietaryConstraints:d,extendedRtpCapabilities:p}){this.assertNotClosed(),m.debug("run()"),this._direction=e,this._remoteSdp=new h.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i}),this._sendingRtpParametersByKind={audio:n.getSendingRtpParameters("audio",p),video:n.getSendingRtpParameters("video",p)},this._sendingRemoteRtpParametersByKind={audio:n.getSendingRemoteRtpParameters("audio",p),video:n.getSendingRemoteRtpParameters("video",p)},s.role&&"auto"!==s.role&&(this._forcedLocalDtlsRole="server"===s.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:o||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...c},d),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(m.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){this.assertNotClosed(),m.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),m.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});m.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();m.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i,onRtpSender:d}){this.assertNotClosed(),this.assertSendDirection(),m.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const p=a.clone(this._sendingRtpParametersByKind[e.kind]);p.codecs=n.reduceCodecs(p.codecs,i);const l=a.clone(this._sendingRemoteRtpParametersByKind[e.kind]);l.codecs=n.reduceCodecs(l.codecs,i);const h=this._remoteSdp.getNextMediaSectionIdx(),f=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});d&&d(f.sender);let g,b=await this._pc.createOffer(),_=s.parse(b.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:_});let y=!1;const w=(0,u.parse)((t||[{}])[0].scalabilityMode);t&&1===t.length&&w.spatialLayers>1&&"video/vp9"===p.codecs[0].mimeType.toLowerCase()&&(m.debug("send() | enabling legacy simulcast for VP9 SVC"),y=!0,_=s.parse(b.sdp),g=_.media[h.idx],c.addLegacySimulcast({offerMediaObject:g,numStreams:w.spatialLayers}),b={type:"offer",sdp:s.write(_)}),m.debug("send() | calling pc.setLocalDescription() [offer:%o]",b),await this._pc.setLocalDescription(b);let v=f.mid??void 0;if(v||m.warn("send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround"),p.mid=v,_=s.parse(this._pc.localDescription.sdp),g=_.media[h.idx],p.rtcp.cname=o.getCname({offerMediaObject:g}),t)if(1===t.length){let e=c.getRtpEncodings({offerMediaObject:g});Object.assign(e[0],t[0]),y&&(e=[e[0]]),p.encodings=e}else p.encodings=t;else p.encodings=c.getRtpEncodings({offerMediaObject:g});if(p.encodings.length>1&&("video/vp8"===p.codecs[0].mimeType.toLowerCase()||"video/h264"===p.codecs[0].mimeType.toLowerCase()))for(const s of p.encodings)s.scalabilityMode?s.scalabilityMode=`L1T${w.temporalLayers}`:s.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:g,reuseMid:h.reuseMid,offerRtpParameters:p,answerRtpParameters:l,codecOptions:r,extmapAllowMixed:!0});const S={type:"answer",sdp:this._remoteSdp.getSdp()};return m.debug("send() | calling pc.setRemoteDescription() [answer:%o]",S),await this._pc.setRemoteDescription(S),v||(v=f.mid,p.mid=v),this._mapMidTransceiver.set(v,f),{localId:v,rtpParameters:p,rtpSender:f.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;m.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");if(t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(i){}const r=await this._pc.createOffer();m.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),m.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();m.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),m.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();m.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const s={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?m.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):m.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),m.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();m.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),m.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const s=r.sender.getParameters();s.encodings.forEach(((e,r)=>{s.encodings[r]={...e,...t}})),await r.sender.setParameters(s),this._remoteSdp.muxMediaSectionSimulcast(e,s.encodings);const i=await this._pc.createOffer();m.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const a={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:a}){this.assertNotClosed(),this.assertSendDirection();const n={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:a};m.debug("sendDataChannel() [options:%o]",n);const o=this._pc.createDataChannel(i,n);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%f.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),m.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:n.id,ordered:n.ordered,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const s of e){const{trackId:e,kind:t,rtpParameters:i,streamId:a}=s;m.debug("receive() [trackId:%s, kind:%s]",e,t);const n=i.mid||String(this._mapMidTransceiver.size);r.set(e,n),this._remoteSdp.receive({mid:n,kind:t,offerRtpParameters:i,streamId:a||i.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);for(const s of e){const{trackId:e,onRtpReceiver:t}=s;if(t){const s=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===s));if(!i)throw new Error("transceiver not found");t(i.receiver)}}let a=await this._pc.createAnswer();const n=s.parse(a.sdp);for(const s of e){const{trackId:e,rtpParameters:t}=s,i=r.get(e),a=n.media.find((e=>String(e.mid)===i));o.applyCodecParameters({offerRtpParameters:t,answerMediaObject:a})}a={type:"answer",sdp:s.write(n)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:n}),m.debug("receive() | calling pc.setLocalDescription() [answer:%o]",a),await this._pc.setLocalDescription(a);for(const s of e){const{trackId:e}=s,i=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===i));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,a),t.push({localId:i,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const s of e){m.debug("stopReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const s of e)this._mapMidTransceiver.delete(s)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){m.debug("pauseReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const s of e){m.debug("resumeReceiving() [localId:%s]",s);const e=this._mapMidTransceiver.get(s);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(s)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o,protocol:r};m.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=o.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new p.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}};return ht.ReactNativeUnifiedPlan=g,ht}(),C=function(){if(ut)return ft;ut=1;var e=ft&&ft.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),t=ft&&ft.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=ft&&ft.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(null!=r)for(var i in r)"default"!==i&&Object.prototype.hasOwnProperty.call(r,i)&&e(s,r,i);return t(s,r),s};Object.defineProperty(ft,"__esModule",{value:!0}),ft.ReactNative=void 0;const s=r(ye()),i=_(),a=T(),n=r(I()),o=r(B()),c=r(Se()),d=r(Je()),p=xe(),l=je(),h=new i.Logger("ReactNative"),u={OS:1024,MIS:1024};let m=class e extends p.HandlerInterface{static createFactory(){return()=>new e}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdTrack=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"ReactNative"}close(){if(h.debug("close()"),this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){h.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const r=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(t){}const i=s.parse(r.sdp);return c.extractRtpCapabilities({sdpObject:i})}catch(t){try{e.close()}catch(r){}throw t}}async getNativeSctpCapabilities(){return h.debug("getNativeSctpCapabilities()"),{numStreams:u}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:n,additionalSettings:c,proprietaryConstraints:d,extendedRtpCapabilities:p}){h.debug("run()"),this._direction=e,this._remoteSdp=new l.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:o.getSendingRtpParameters("audio",p),video:o.getSendingRtpParameters("video",p)},this._sendingRemoteRtpParametersByKind={audio:o.getSendingRemoteRtpParameters("audio",p),video:o.getSendingRemoteRtpParameters("video",p)},s.role&&"auto"!==s.role&&(this._forcedLocalDtlsRole="server"===s.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:n||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...c},d),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(h.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){h.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(h.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});h.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();h.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertSendDirection(),h.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),i&&h.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addStream(this._sendStream);let a,p=await this._pc.createOffer(),l=s.parse(p.sdp);const u=n.clone(this._sendingRtpParametersByKind[e.kind]);u.codecs=o.reduceCodecs(u.codecs);const m=n.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(m.codecs=o.reduceCodecs(m.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l}),"video"===e.kind&&t&&t.length>1&&(h.debug("send() | enabling simulcast"),l=s.parse(p.sdp),a=l.media.find((e=>"video"===e.type)),d.addLegacySimulcast({offerMediaObject:a,track:e,numStreams:t.length}),p={type:"offer",sdp:s.write(l)}),h.debug("send() | calling pc.setLocalDescription() [offer:%o]",p),await this._pc.setLocalDescription(p),l=s.parse(this._pc.localDescription.sdp),a=l.media.find((t=>t.type===e.kind)),u.rtcp.cname=c.getCname({offerMediaObject:a}),u.encodings=d.getRtpEncodings({offerMediaObject:a,track:e}),t)for(let s=0;s<u.encodings.length;++s)t[s]&&Object.assign(u.encodings[s],t[s]);if(u.encodings.length>1&&("video/vp8"===u.codecs[0].mimeType.toLowerCase()||"video/h264"===u.codecs[0].mimeType.toLowerCase()))for(const s of u.encodings)s.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:a,offerRtpParameters:u,answerRtpParameters:m,codecOptions:r});const f={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f);const g=String(this._nextSendLocalId);return this._nextSendLocalId++,this._mapSendLocalIdTrack.set(g,e),{localId:g,rtpParameters:u}}async stopSending(e){this.assertSendDirection(),h.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdTrack.get(e);if(!t)throw new Error("track not found");this._mapSendLocalIdTrack.delete(e),this._sendStream.removeTrack(t),this._pc.addStream(this._sendStream);const r=await this._pc.createOffer();h.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(i){if(0===this._sendStream.getTracks().length)return void h.warn("stopSending() | ignoring expected error due no sending tracks: %s",i.toString());throw i}if("stable"===this._pc.signalingState)return;const s={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){throw new a.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new a.UnsupportedError("not implemented")}async setRtpEncodingParameters(e,t){throw new a.UnsupportedError("not implemented")}async getSenderStats(e){throw new a.UnsupportedError("not implemented")}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:a}){this.assertSendDirection();const n={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:a};h.debug("sendDataChannel() [options:%o]",n);const o=this._pc.createDataChannel(i,n);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%u.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),h.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};h.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:n.id,ordered:n.ordered,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[],r=new Map;for(const s of e){const{trackId:e,kind:t,rtpParameters:i}=s;h.debug("receive() [trackId:%s, kind:%s]",e,t);const a=t;let o=s.streamId||i.rtcp.cname;h.debug("receive() | forcing a random remote streamId to avoid well known bug in react-native-webrtc"),o+=`-hack-${n.generateRandomNumber()}`,r.set(e,o),this._remoteSdp.receive({mid:a,kind:t,offerRtpParameters:i,streamId:o,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);let a=await this._pc.createAnswer();const o=s.parse(a.sdp);for(const s of e){const{kind:e,rtpParameters:t}=s,r=e,i=o.media.find((e=>String(e.mid)===r));c.applyCodecParameters({offerRtpParameters:t,answerMediaObject:i})}a={type:"answer",sdp:s.write(o)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),h.debug("receive() | calling pc.setLocalDescription() [answer:%o]",a),await this._pc.setLocalDescription(a);for(const s of e){const{kind:e,trackId:i,rtpParameters:a}=s,n=i,o=e,c=r.get(i),d=this._pc.getRemoteStreams().find((e=>e.id===c)).getTrackById(n);if(!d)throw new Error("remote track not found");this._mapRecvLocalIdInfo.set(n,{mid:o,rtpParameters:a}),t.push({localId:n,track:d})}return t}async stopReceiving(e){this.assertRecvDirection();for(const s of e){h.debug("stopReceiving() [localId:%s]",s);const{mid:e,rtpParameters:t}=this._mapRecvLocalIdInfo.get(s)||{};this._mapRecvLocalIdInfo.delete(s),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:t})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();h.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new a.UnsupportedError("not implemented")}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:i,ordered:a,maxPacketLifeTime:n,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:a,maxPacketLifeTime:n,maxRetransmitTime:n,maxRetransmits:o,protocol:r};h.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};h.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}h.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=c.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}};return ft.ReactNative=m,ft}(),k=new i.Logger("Device");function D(){if("object"==typeof navigator&&"ReactNative"===navigator.product)return k.debug("detectDevice() | React-Native detected"),"undefined"==typeof RTCPeerConnection?void k.warn("detectDevice() | unsupported react-native-webrtc without RTCPeerConnection, forgot to call registerGlobals()?"):"undefined"!=typeof RTCRtpTransceiver?(k.debug("detectDevice() | ReactNative UnifiedPlan handler chosen"),"ReactNativeUnifiedPlan"):(k.debug("detectDevice() | ReactNative PlanB handler chosen"),"ReactNative");if("object"!=typeof navigator||"string"!=typeof navigator.userAgent)k.warn("detectDevice() | unknown device");else{const e=navigator.userAgent,t=new s.UAParser(e);k.debug("detectDevice() | browser detected [ua:%s, parsed:%o]",e,t.getResult());const r=t.getBrowser(),i=r.name?.toLowerCase(),a=parseInt(r.major??"0"),n=t.getEngine(),o=n.name?.toLowerCase(),c=t.getOS(),d=c.name?.toLowerCase(),p=parseFloat(c.version??"0"),l=t.getDevice(),h=l.model?.toLowerCase(),u="ios"===d||"ipad"===h,m=i&&["chrome","chromium","mobile chrome","chrome webview","chrome headless"].includes(i),f=i&&["firefox","mobile firefox","mobile focus"].includes(i),g=i&&["safari","mobile safari"].includes(i),b=i&&["edge"].includes(i);if((m||b)&&!u&&a>=111)return"Chrome111";if(m&&!u&&a>=74||b&&!u&&a>=88)return"Chrome74";if(m&&!u&&a>=70)return"Chrome70";if(m&&!u&&a>=67)return"Chrome67";if(m&&!u&&a>=55)return"Chrome55";if(f&&!u&&a>=120)return"Firefox120";if(f&&!u&&a>=60)return"Firefox60";if(f&&u&&p>=14.3)return"Safari12";if(g&&a>=12&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(g&&a>=11)return"Safari11";if(b&&!u&&a>=11&&a<=18)return"Edge11";if("webkit"===o&&u&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if("blink"===o){const t=e.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);if(t){const e=Number(t[1]);return e>=111?"Chrome111":e>=74?"Chrome74":e>=70?"Chrome70":e>=67?"Chrome67":"Chrome55"}return"Chrome111"}k.warn("detectDevice() | browser not supported [name:%s, version:%s]",i,a)}}return h.Device=class{constructor({handlerName:e,handlerFactory:t,Handler:r}={}){if(this._loaded=!1,this._observer=new a.EnhancedEventEmitter,k.debug("constructor()"),r){if(k.warn("constructor() | Handler option is DEPRECATED, use handlerName or handlerFactory instead"),"string"!=typeof r)throw new TypeError("non string Handler option no longer supported, use handlerFactory instead");e=r}if(e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(t)this._handlerFactory=t;else{if(e)k.debug("constructor() | handler given: %s",e);else{if(!(e=D()))throw new n.UnsupportedError("device not supported");k.debug("constructor() | detected handler: %s",e)}switch(e){case"Chrome111":this._handlerFactory=p.Chrome111.createFactory();break;case"Chrome74":this._handlerFactory=l.Chrome74.createFactory();break;case"Chrome70":this._handlerFactory=u.Chrome70.createFactory();break;case"Chrome67":this._handlerFactory=m.Chrome67.createFactory();break;case"Chrome55":this._handlerFactory=g.Chrome55.createFactory();break;case"Firefox120":this._handlerFactory=b.Firefox120.createFactory();break;case"Firefox60":this._handlerFactory=y.Firefox60.createFactory();break;case"Safari12":this._handlerFactory=w.Safari12.createFactory();break;case"Safari11":this._handlerFactory=v.Safari11.createFactory();break;case"Edge11":this._handlerFactory=S.Edge11.createFactory();break;case"ReactNativeUnifiedPlan":this._handlerFactory=R.ReactNativeUnifiedPlan.createFactory();break;case"ReactNative":this._handlerFactory=C.ReactNative.createFactory();break;default:throw new TypeError(`unknown handlerName "${e}"`)}}const s=this._handlerFactory();this._handlerName=s.name,s.close(),this._extendedRtpCapabilities=void 0,this._recvRtpCapabilities=void 0,this._canProduceByKind={audio:!1,video:!1},this._sctpCapabilities=void 0}get handlerName(){return this._handlerName}get loaded(){return this._loaded}get rtpCapabilities(){if(!this._loaded)throw new n.InvalidStateError("not loaded");return this._recvRtpCapabilities}get sctpCapabilities(){if(!this._loaded)throw new n.InvalidStateError("not loaded");return this._sctpCapabilities}get observer(){return this._observer}async load({routerRtpCapabilities:e}){let t;k.debug("load() [routerRtpCapabilities:%o]",e);try{if(this._loaded)throw new n.InvalidStateError("already loaded");const r=o.clone(e);c.validateRtpCapabilities(r),t=this._handlerFactory();const s=await t.getNativeRtpCapabilities();k.debug("load() | got native RTP capabilities:%o",s);const i=o.clone(s);c.validateRtpCapabilities(i),this._extendedRtpCapabilities=c.getExtendedRtpCapabilities(i,r),k.debug("load() | got extended RTP capabilities:%o",this._extendedRtpCapabilities),this._canProduceByKind.audio=c.canSend("audio",this._extendedRtpCapabilities),this._canProduceByKind.video=c.canSend("video",this._extendedRtpCapabilities),this._recvRtpCapabilities=c.getRecvRtpCapabilities(this._extendedRtpCapabilities),c.validateRtpCapabilities(this._recvRtpCapabilities),k.debug("load() | got receiving RTP capabilities:%o",this._recvRtpCapabilities),this._sctpCapabilities=await t.getNativeSctpCapabilities(),k.debug("load() | got native SCTP capabilities:%o",this._sctpCapabilities),c.validateSctpCapabilities(this._sctpCapabilities),k.debug("load() succeeded"),this._loaded=!0,t.close()}catch(r){throw t&&t.close(),r}}canProduce(e){if(!this._loaded)throw new n.InvalidStateError("not loaded");if("audio"!==e&&"video"!==e)throw new TypeError(`invalid kind "${e}"`);return this._canProduceByKind[e]}createSendTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:n,additionalSettings:o,proprietaryConstraints:c,appData:d}){return k.debug("createSendTransport()"),this.createTransport({direction:"send",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:n,additionalSettings:o,proprietaryConstraints:c,appData:d})}createRecvTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:n,additionalSettings:o,proprietaryConstraints:c,appData:d}){return k.debug("createRecvTransport()"),this.createTransport({direction:"recv",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:s,sctpParameters:i,iceServers:a,iceTransportPolicy:n,additionalSettings:o,proprietaryConstraints:c,appData:d})}createTransport({direction:e,id:t,iceParameters:r,iceCandidates:s,dtlsParameters:i,sctpParameters:a,iceServers:o,iceTransportPolicy:c,additionalSettings:p,proprietaryConstraints:l,appData:h}){if(!this._loaded)throw new n.InvalidStateError("not loaded");if("string"!=typeof t)throw new TypeError("missing id");if("object"!=typeof r)throw new TypeError("missing iceParameters");if(!Array.isArray(s))throw new TypeError("missing iceCandidates");if("object"!=typeof i)throw new TypeError("missing dtlsParameters");if(a&&"object"!=typeof a)throw new TypeError("wrong sctpParameters");if(h&&"object"!=typeof h)throw new TypeError("if given, appData must be an object");const u=new d.Transport({direction:e,id:t,iceParameters:r,iceCandidates:s,dtlsParameters:i,sctpParameters:a,iceServers:o,iceTransportPolicy:c,additionalSettings:p,proprietaryConstraints:l,appData:h,handlerFactory:this._handlerFactory,extendedRtpCapabilities:this._extendedRtpCapabilities,canProduceByKind:this._canProduceByKind});return this._observer.safeEmit("newtransport",u),u}},h}var bt,_t={},yt={};var wt,vt,St,Rt={};function Pt(){return vt||(vt=1,e=_t,t=_t&&_t.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),r=_t&&_t.__exportStar||function(e,r){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(r,s)||t(r,e,s)},Object.defineProperty(e,"__esModule",{value:!0}),r(gt(),e),r(ne(),e),r(J(),e),r(Y(),e),r(te(),e),r(ae(),e),r((bt||(bt=1,Object.defineProperty(yt,"__esModule",{value:!0})),yt),e),r((wt||(wt=1,Object.defineProperty(Rt,"__esModule",{value:!0})),Rt),e),r(xe(),e),r(T(),e)),_t;var e,t,r}var Ct=(St||(St=1,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,i)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),r=o&&o.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=o&&o.__importStar||function(e){if(e&&e.__esModule)return e;var s={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&t(s,e,i);return r(s,e),s},i=o&&o.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.debug=e.parseScalabilityMode=e.detectDevice=e.Device=e.version=e.types=void 0;const a=i(p());e.debug=a.default;const n=gt();Object.defineProperty(e,"Device",{enumerable:!0,get:function(){return n.Device}}),Object.defineProperty(e,"detectDevice",{enumerable:!0,get:function(){return n.detectDevice}});const c=s(Pt());e.types=c,e.version="3.7.12";var d=$e();Object.defineProperty(e,"parseScalabilityMode",{enumerable:!0,get:function(){return d.parse}})}(o)),o);const kt={"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"},Tt={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"},Dt={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},Et={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"},It={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};class xt{static getFirstMatch(e,t){const r=t.match(e);return r&&r.length>0&&r[1]||""}static getSecondMatch(e,t){const r=t.match(e);return r&&r.length>1&&r[2]||""}static matchAndReturnConst(e,t,r){if(e.test(t))return r}static getWindowsVersionName(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}}static getMacOSVersionName(e){const t=e.split(".").splice(0,2).map((e=>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}}static getAndroidVersionName(e){const t=e.split(".").splice(0,2).map((e=>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}static getVersionPrecision(e){return e.split(".").length}static compareVersions(e,t,r=!1){const s=xt.getVersionPrecision(e),i=xt.getVersionPrecision(t);let a=Math.max(s,i),n=0;const o=xt.map([e,t],(e=>{const t=a-xt.getVersionPrecision(e),r=e+new Array(t+1).join(".0");return xt.map(r.split("."),(e=>new Array(20-e.length).join("0")+e)).reverse()}));for(r&&(n=a-Math.min(s,i)),a-=1;a>=n;){if(o[0][a]>o[1][a])return 1;if(o[0][a]===o[1][a]){if(a===n)return 0;a-=1}else if(o[0][a]<o[1][a])return-1}}static map(e,t){const r=[];let s;if(Array.prototype.map)return Array.prototype.map.call(e,t);for(s=0;s<e.length;s+=1)r.push(t(e[s]));return r}static find(e,t){let r,s;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(r=0,s=e.length;r<s;r+=1){const s=e[r];if(t(s,r))return s}}static assign(e,...t){const r=e;let s,i;if(Object.assign)return Object.assign(e,...t);for(s=0,i=t.length;s<i;s+=1){const e=t[s];if("object"==typeof e&&null!==e){Object.keys(e).forEach((t=>{r[t]=e[t]}))}}return e}static getBrowserAlias(e){return kt[e]}static getBrowserTypeByAlias(e){return Tt[e]||""}}const Mt=/version\/(\d+(\.?_?\d+)+)/i,Ot=[{test:[/googlebot/i],describe(e){const t={name:"Googlebot"},r=xt.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/opera/i],describe(e){const t={name:"Opera"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe(e){const t={name:"Opera"},r=xt.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe(e){const t={name:"Samsung Internet for Android"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe(e){const t={name:"NAVER Whale Browser"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe(e){const t={name:"MZ Browser"},r=xt.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/focus/i],describe(e){const t={name:"Focus"},r=xt.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/swing/i],describe(e){const t={name:"Swing"},r=xt.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/coast/i],describe(e){const t={name:"Opera Coast"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe(e){const t={name:"Opera Touch"},r=xt.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe(e){const t={name:"Yandex Browser"},r=xt.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe(e){const t={name:"UC Browser"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe(e){const t={name:"Maxthon"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe(e){const t={name:"Epiphany"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe(e){const t={name:"Puffin"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe(e){const t={name:"Sleipnir"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe(e){const t={name:"K-Meleon"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe(e){const t={name:"WeChat"},r=xt.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe(e){const t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=xt.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe(e){const t={name:"Internet Explorer"},r=xt.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe(e){const t={name:"Microsoft Edge"},r=xt.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe(e){const t={name:"Microsoft Edge"},r=xt.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe(e){const t={name:"Vivaldi"},r=xt.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe(e){const t={name:"SeaMonkey"},r=xt.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe(e){const t={name:"Sailfish"},r=xt.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe(e){const t={name:"Amazon Silk"},r=xt.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe(e){const t={name:"PhantomJS"},r=xt.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe(e){const t={name:"SlimerJS"},r=xt.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t={name:"BlackBerry"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe(e){const t={name:"WebOS Browser"},r=xt.getFirstMatch(Mt,e)||xt.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe(e){const t={name:"Bada"},r=xt.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe(e){const t={name:"Tizen"},r=xt.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe(e){const t={name:"QupZilla"},r=xt.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe(e){const t={name:"Firefox"},r=xt.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe(e){const t={name:"Electron"},r=xt.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe(e){const t={name:"Miui"},r=xt.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe(e){const t={name:"Chromium"},r=xt.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe(e){const t={name:"Chrome"},r=xt.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe(e){const t={name:"Google Search"},r=xt.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test(e){const t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe(e){const t={name:"Android Browser"},r=xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe(e){const t={name:"PlayStation 4"},r=xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe(e){const t={name:"Safari"},r=xt.getFirstMatch(Mt,e);return r&&(t.version=r),t}},{test:[/.*/i],describe(e){const t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:xt.getFirstMatch(t,e),version:xt.getSecondMatch(t,e)}}}],Lt=[{test:[/Roku\/DVP/],describe(e){const t=xt.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:Et.Roku,version:t}}},{test:[/windows phone/i],describe(e){const t=xt.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:Et.WindowsPhone,version:t}}},{test:[/windows /i],describe(e){const t=xt.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=xt.getWindowsVersionName(t);return{name:Et.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(e){const t={name:Et.iOS},r=xt.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe(e){const t=xt.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=xt.getMacOSVersionName(t),s={name:Et.MacOS,version:t};return r&&(s.versionName=r),s}},{test:[/(ipod|iphone|ipad)/i],describe(e){const t=xt.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:Et.iOS,version:t}}},{test(e){const t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe(e){const t=xt.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=xt.getAndroidVersionName(t),s={name:Et.Android,version:t};return r&&(s.versionName=r),s}},{test:[/(web|hpw)[o0]s/i],describe(e){const t=xt.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:Et.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t=xt.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||xt.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||xt.getFirstMatch(/\bbb(\d+)/i,e);return{name:Et.BlackBerry,version:t}}},{test:[/bada/i],describe(e){const t=xt.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:Et.Bada,version:t}}},{test:[/tizen/i],describe(e){const t=xt.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:Et.Tizen,version:t}}},{test:[/linux/i],describe:()=>({name:Et.Linux})},{test:[/CrOS/],describe:()=>({name:Et.ChromeOS})},{test:[/PlayStation 4/],describe(e){const t=xt.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:Et.PlayStation4,version:t}}}],At=[{test:[/googlebot/i],describe:()=>({type:"bot",vendor:"Google"})},{test:[/huawei/i],describe(e){const t=xt.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:Dt.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:()=>({type:Dt.tablet,vendor:"Nexus"})},{test:[/ipad/i],describe:()=>({type:Dt.tablet,vendor:"Apple",model:"iPad"})},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:()=>({type:Dt.tablet,vendor:"Apple",model:"iPad"})},{test:[/kftt build/i],describe:()=>({type:Dt.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"})},{test:[/silk/i],describe:()=>({type:Dt.tablet,vendor:"Amazon"})},{test:[/tablet(?! pc)/i],describe:()=>({type:Dt.tablet})},{test(e){const t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe(e){const t=xt.getFirstMatch(/(ipod|iphone)/i,e);return{type:Dt.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:()=>({type:Dt.mobile,vendor:"Nexus"})},{test:[/[^-]mobi/i],describe:()=>({type:Dt.mobile})},{test:e=>"blackberry"===e.getBrowserName(!0),describe:()=>({type:Dt.mobile,vendor:"BlackBerry"})},{test:e=>"bada"===e.getBrowserName(!0),describe:()=>({type:Dt.mobile})},{test:e=>"windows phone"===e.getBrowserName(),describe:()=>({type:Dt.mobile,vendor:"Microsoft"})},{test(e){const t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:()=>({type:Dt.tablet})},{test:e=>"android"===e.getOSName(!0),describe:()=>({type:Dt.mobile})},{test:e=>"macos"===e.getOSName(!0),describe:()=>({type:Dt.desktop,vendor:"Apple"})},{test:e=>"windows"===e.getOSName(!0),describe:()=>({type:Dt.desktop})},{test:e=>"linux"===e.getOSName(!0),describe:()=>({type:Dt.desktop})},{test:e=>"playstation 4"===e.getOSName(!0),describe:()=>({type:Dt.tv})},{test:e=>"roku"===e.getOSName(!0),describe:()=>({type:Dt.tv})}],jt=[{test:e=>"microsoft edge"===e.getBrowserName(!0),describe(e){if(/\sedg\//i.test(e))return{name:It.Blink};const t=xt.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:It.EdgeHTML,version:t}}},{test:[/trident/i],describe(e){const t={name:It.Trident},r=xt.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:e=>e.test(/presto/i),describe(e){const t={name:It.Presto},r=xt.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test(e){const t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe(e){const t={name:It.Gecko},r=xt.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:It.Blink})},{test:[/(apple)?webkit/i],describe(e){const t={name:It.WebKit},r=xt.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];class Nt{constructor(e,t=!1){if(null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}getUA(){return this._ua}test(e){return e.test(this._ua)}parseBrowser(){this.parsedResult.browser={};const e=xt.find(Ot,(e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some((e=>this.test(e)));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser}getBrowser(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()}getBrowserName(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""}getBrowserVersion(){return this.getBrowser().version}getOS(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()}parseOS(){this.parsedResult.os={};const e=xt.find(Lt,(e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some((e=>this.test(e)));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os}getOSName(e){const{name:t}=this.getOS();return e?String(t).toLowerCase()||"":t||""}getOSVersion(){return this.getOS().version}getPlatform(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()}getPlatformType(e=!1){const{type:t}=this.getPlatform();return e?String(t).toLowerCase()||"":t||""}parsePlatform(){this.parsedResult.platform={};const e=xt.find(At,(e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some((e=>this.test(e)));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform}getEngine(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()}getEngineName(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""}parseEngine(){this.parsedResult.engine={};const e=xt.find(jt,(e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some((e=>this.test(e)));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.engine=e.describe(this.getUA())),this.parsedResult.engine}parse(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this}getResult(){return xt.assign({},this.parsedResult)}satisfies(e){const t={};let r=0;const s={};let i=0;if(Object.keys(e).forEach((a=>{const n=e[a];"string"==typeof n?(s[a]=n,i+=1):"object"==typeof n&&(t[a]=n,r+=1)})),r>0){const e=Object.keys(t),r=xt.find(e,(e=>this.isOS(e)));if(r){const e=this.satisfies(t[r]);if(void 0!==e)return e}const s=xt.find(e,(e=>this.isPlatform(e)));if(s){const e=this.satisfies(t[s]);if(void 0!==e)return e}}if(i>0){const e=Object.keys(s),t=xt.find(e,(e=>this.isBrowser(e,!0)));if(void 0!==t)return this.compareVersion(s[t])}}isBrowser(e,t=!1){const r=this.getBrowserName().toLowerCase();let s=e.toLowerCase();const i=xt.getBrowserTypeByAlias(s);return t&&i&&(s=i.toLowerCase()),s===r}compareVersion(e){let t=[0],r=e,s=!1;const i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(s=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(s=!0,r=e.substr(1)),t.indexOf(xt.compareVersions(i,r,s))>-1}isOS(e){return this.getOSName(!0)===String(e).toLowerCase()}isPlatform(e){return this.getPlatformType(!0)===String(e).toLowerCase()}isEngine(e){return this.getEngineName(!0)===String(e).toLowerCase()}is(e,t=!1){return this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)}some(e=[]){return e.some((e=>this.is(e)))}}
|
|
9
3
|
/*!
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
"use strict";var t=e("base64-js"),i=e("ieee754");r.Buffer=s,r.SlowBuffer=function(e){+e!=e&&(e=0);return s.alloc(+e)},r.INSPECT_MAX_BYTES=50;var n=2147483647;function a(e){if(e>n)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(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 d(e)}return o(e,t,r)}function o(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|h(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 u(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(U(e,ArrayBuffer)||e&&U(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__=s.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 s.from(i,t,r);var n=function(e){if(s.isBuffer(e)){var t=0|l(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||q(e.length)?a(0):u(e);if("Buffer"===e.type&&Array.isArray(e.data))return u(e.data)}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return s.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 c(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 d(e){return c(e),a(e<0?0:0|l(e))}function u(e){for(var t=e.length<0?0:0|l(e.length),r=a(t),i=0;i<t;i+=1)r[i]=255&e[i];return r}function l(e){if(e>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return 0|e}function h(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||U(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 B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return N(e).length;default:if(n)return i?-1:B(e).length;t=(""+t).toLowerCase(),n=!0}}function f(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 R(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return E(this,t,r);case"base64":return k(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function p(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),q(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=s.from(t,i)),s.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 a,s=1,o=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,o/=2,c/=2,r/=2}function d(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var u=-1;for(a=r;a<o;a++)if(d(e,a)===d(t,-1===u?0:a-u)){if(-1===u&&(u=a),a-u+1===c)return u*s}else-1!==u&&(a-=a-u),u=-1}else for(r+c>o&&(r=o-c),a=r;a>=0;a--){for(var l=!0,h=0;h<c;h++)if(d(e,a+h)!==d(t,h)){l=!1;break}if(l)return a}return-1}function g(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i))>n&&(i=n):i=n;var a=t.length;i>a/2&&(i=a/2);for(var s=0;s<i;++s){var o=parseInt(t.substr(2*s,2),16);if(q(o))return s;e[r+s]=o}return s}function v(e,t,r,i){return F(B(t,e.length-r),e,r,i)}function y(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 _(e,t,r,i){return y(e,t,r,i)}function w(e,t,r,i){return F(N(t),e,r,i)}function S(e,t,r,i){return F(function(e,t){for(var r,i,n,a=[],s=0;s<e.length&&!((t-=2)<0);++s)i=(r=e.charCodeAt(s))>>8,n=r%256,a.push(n),a.push(i);return a}(t,e.length-r),e,r,i)}function k(e,r,i){return 0===r&&i===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,i))}function R(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var a,s,o,c,d=e[n],u=null,l=d>239?4:d>223?3:d>191?2:1;if(n+l<=r)switch(l){case 1:d<128&&(u=d);break;case 2:128==(192&(a=e[n+1]))&&(c=(31&d)<<6|63&a)>127&&(u=c);break;case 3:a=e[n+1],s=e[n+2],128==(192&a)&&128==(192&s)&&(c=(15&d)<<12|(63&a)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:a=e[n+1],s=e[n+2],o=e[n+3],128==(192&a)&&128==(192&s)&&128==(192&o)&&(c=(15&d)<<18|(63&a)<<12|(63&s)<<6|63&o)>65535&&c<1114112&&(u=c)}null===u?(u=65533,l=1):u>65535&&(u-=65536,i.push(u>>>10&1023|55296),u=56320|1023&u),i.push(u),n+=l}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)}r.kMaxLength=n,s.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}}(),s.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(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),s.poolSize=8192,s.from=function(e,t,r){return o(e,t,r)},s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,s.alloc=function(e,t,r){return function(e,t,r){return c(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)},s.allocUnsafe=function(e){return d(e)},s.allocUnsafeSlow=function(e){return d(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(U(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),U(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.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,a=Math.min(r,i);n<a;++n)if(e[n]!==t[n]){r=e[n],i=t[n];break}return r<i?-1:i<r?1:0},s.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}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var i=s.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var a=e[r];if(U(a,Uint8Array)&&(a=s.from(a)),!s.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(i,n),n+=a.length}return i},s.byteLength=h,s.prototype._isBuffer=!0,s.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)p(this,t,t+1);return this},s.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)p(this,t,t+3),p(this,t+1,t+2);return this},s.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)p(this,t,t+7),p(this,t+1,t+6),p(this,t+2,t+5),p(this,t+3,t+4);return this},s.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?R(this,0,e):f.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s.prototype.compare=function(e,t,r,i,n){if(U(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.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 a=(n>>>=0)-(i>>>=0),o=(r>>>=0)-(t>>>=0),c=Math.min(a,o),d=this.slice(i,n),u=e.slice(t,r),l=0;l<c;++l)if(d[l]!==u[l]){a=d[l],o=u[l];break}return a<o?-1:o<a?1:0},s.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},s.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},s.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)},s.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 a=!1;;)switch(i){case"hex":return g(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return y(this,e,t,r);case"latin1":case"binary":return _(this,e,t,r);case"base64":return w(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var P=4096;function M(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 E(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="",a=t;a<r;++a)n+=j(e[a]);return n}function T(e,t,r){for(var i=e.slice(t,r),n="",a=0;a<i.length;a+=2)n+=String.fromCharCode(i[a]+256*i[a+1]);return n}function C(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 I(e,t,r,i,n,a){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<a)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function D(e,t,r,i,n,a){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O(e,t,r,n,a){return t=+t,r>>>=0,a||D(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function A(e,t,r,n,a){return t=+t,r>>>=0,a||D(e,0,r,8),i.write(e,t,r,n,52,8),r+8}s.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__=s.prototype,i},s.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||C(e,t,this.length);for(var i=this[e],n=1,a=0;++a<t&&(n*=256);)i+=this[e+a]*n;return i},s.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||C(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},s.prototype.readUInt8=function(e,t){return e>>>=0,t||C(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||C(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||C(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||C(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||C(e,t,this.length);for(var i=this[e],n=1,a=0;++a<t&&(n*=256);)i+=this[e+a]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||C(e,t,this.length);for(var i=t,n=1,a=this[e+--i];i>0&&(n*=256);)a+=this[e+--i]*n;return a>=(n*=128)&&(a-=Math.pow(2,8*t)),a},s.prototype.readInt8=function(e,t){return e>>>=0,t||C(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||C(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||C(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||C(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||C(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||C(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||C(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,a=0;for(this[t]=255&e;++a<r&&(n*=256);)this[t+a]=e/n&255;return t+r},s.prototype.writeUIntBE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,a=1;for(this[t+n]=255&e;--n>=0&&(a*=256);)this[t+n]=e/a&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||I(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},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||I(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},s.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);I(this,e,t,r,n-1,-n)}var a=0,s=1,o=0;for(this[t]=255&e;++a<r&&(s*=256);)e<0&&0===o&&0!==this[t+a-1]&&(o=1),this[t+a]=(e/s|0)-o&255;return t+r},s.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);I(this,e,t,r,n-1,-n)}var a=r-1,s=1,o=0;for(this[t+a]=255&e;--a>=0&&(s*=256);)e<0&&0===o&&0!==this[t+a+1]&&(o=1),this[t+a]=(e/s|0)-o&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||I(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},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||I(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},s.prototype.writeFloatLE=function(e,t,r){return O(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return O(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return A(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return A(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,i){if(!s.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 a=n-1;a>=0;--a)e[a+t]=this[a+r];else Uint8Array.prototype.set.call(e,this.subarray(r,i),t);return n},s.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&&!s.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 a;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(a=t;a<r;++a)this[a]=e;else{var o=s.isBuffer(e)?e:s.from(e,i),c=o.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<r-t;++a)this[a+t]=o[a%c]}return this};var L=/[^+/0-9A-Za-z-_]/g;function j(e){return e<16?"0"+e.toString(16):e.toString(16)}function B(e,t){var r;t=t||1/0;for(var i=e.length,n=null,a=[],s=0;s<i;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(s+1===i){(t-=3)>-1&&a.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&a.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.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;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function N(e){return t.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 U(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function q(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":59,buffer:94,ieee754:173}],95:[function(e,t,r){var i=e("safe-buffer").Buffer,n=e("stream").Transform,a=e("string_decoder").StringDecoder;function s(e){n.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(s,n),s.prototype.update=function(e,t,r){"string"==typeof e&&(e=i.from(e,t));var n=this._update(e);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},s.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},s.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},s.prototype._transform=function(e,t,r){var i;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){i=e}finally{r(i)}},s.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},s.prototype._finalOrDigest=function(e){var t=this.__final()||i.alloc(0);return e&&(t=this._toString(t,e,!0)),t},s.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new a(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var i=this._decoder.write(e);return r&&(i+=this._decoder.end()),i},t.exports=s},{inherits:174,"safe-buffer":284,stream:306,string_decoder:307}],96:[function(e,t,r){function i(e){return Object.prototype.toString.call(e)}r.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===i(e)},r.isBoolean=function(e){return"boolean"==typeof e},r.isNull=function(e){return null===e},r.isNullOrUndefined=function(e){return null==e},r.isNumber=function(e){return"number"==typeof e},r.isString=function(e){return"string"==typeof e},r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=function(e){return void 0===e},r.isRegExp=function(e){return"[object RegExp]"===i(e)},r.isObject=function(e){return"object"==typeof e&&null!==e},r.isDate=function(e){return"[object Date]"===i(e)},r.isError=function(e){return"[object Error]"===i(e)||e instanceof Error},r.isFunction=function(e){return"function"==typeof e},r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("buffer").Buffer.isBuffer},{buffer:94}],97:[function(e,t,r){(function(r){(function(){var i=e("elliptic"),n=e("bn.js");t.exports=function(e){return new s(e)};var a={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function s(e){this.curveType=a[e],this.curveType||(this.curveType={name:e}),this.curve=new i.ec(this.curveType.name),this.keys=void 0}function o(e,t,i){Array.isArray(e)||(e=e.toArray());var n=new r(e);if(i&&n.length<i){var a=new r(i-n.length);a.fill(0),n=r.concat([a,n])}return t?n.toString(t):n}a.p224=a.secp224r1,a.p256=a.secp256r1=a.prime256v1,a.p192=a.secp192r1=a.prime192v1,a.p384=a.secp384r1,a.p521=a.secp521r1,s.prototype.generateKeys=function(e,t){return this.keys=this.curve.genKeyPair(),this.getPublicKey(e,t)},s.prototype.computeSecret=function(e,t,i){return t=t||"utf8",r.isBuffer(e)||(e=new r(e,t)),o(this.curve.keyFromPublic(e).getPublic().mul(this.keys.getPrivate()).getX(),i,this.curveType.byteLength)},s.prototype.getPublicKey=function(e,t){var r=this.keys.getPublic("compressed"===t,!0);return"hybrid"===t&&(r[r.length-1]%2?r[0]=7:r[0]=6),o(r,e)},s.prototype.getPrivateKey=function(e){return o(this.keys.getPrivate(),e)},s.prototype.setPublicKey=function(e,t){return t=t||"utf8",r.isBuffer(e)||(e=new r(e,t)),this.keys._importPublic(e),this},s.prototype.setPrivateKey=function(e,t){t=t||"utf8",r.isBuffer(e)||(e=new r(e,t));var i=new n(e);return i=i.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(i),this}}).call(this)}).call(this,e("buffer").Buffer)},{"bn.js":98,buffer:94,elliptic:119}],98:[function(e,t,r){arguments[4][55][0].apply(r,arguments)},{buffer:63,dup:55}],99:[function(e,t,r){"use strict";var i=e("inherits"),n=e("md5.js"),a=e("ripemd160"),s=e("sha.js"),o=e("cipher-base");function c(e){o.call(this,"digest"),this._hash=e}i(c,o),c.prototype._update=function(e){this._hash.update(e)},c.prototype._final=function(){return this._hash.digest()},t.exports=function(e){return"md5"===(e=e.toLowerCase())?new n:"rmd160"===e||"ripemd160"===e?new a:new c(s(e))}},{"cipher-base":95,inherits:174,"md5.js":200,ripemd160:283,"sha.js":290}],100:[function(e,t,r){var i=e("md5.js");t.exports=function(e){return(new i).update(e).digest()}},{"md5.js":200}],101:[function(e,t,r){"use strict";var i=e("inherits"),n=e("./legacy"),a=e("cipher-base"),s=e("safe-buffer").Buffer,o=e("create-hash/md5"),c=e("ripemd160"),d=e("sha.js"),u=s.alloc(128);function l(e,t){a.call(this,"digest"),"string"==typeof t&&(t=s.from(t));var r="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>r)?t=("rmd160"===e?new c:d(e)).update(t).digest():t.length<r&&(t=s.concat([t,u],r));for(var i=this._ipad=s.allocUnsafe(r),n=this._opad=s.allocUnsafe(r),o=0;o<r;o++)i[o]=54^t[o],n[o]=92^t[o];this._hash="rmd160"===e?new c:d(e),this._hash.update(i)}i(l,a),l.prototype._update=function(e){this._hash.update(e)},l.prototype._final=function(){var e=this._hash.digest();return("rmd160"===this._alg?new c:d(this._alg)).update(this._opad).update(e).digest()},t.exports=function(e,t){return"rmd160"===(e=e.toLowerCase())||"ripemd160"===e?new l("rmd160",t):"md5"===e?new n(o,t):new l(e,t)}},{"./legacy":102,"cipher-base":95,"create-hash/md5":100,inherits:174,ripemd160:283,"safe-buffer":284,"sha.js":290}],102:[function(e,t,r){"use strict";var i=e("inherits"),n=e("safe-buffer").Buffer,a=e("cipher-base"),s=n.alloc(128),o=64;function c(e,t){a.call(this,"digest"),"string"==typeof t&&(t=n.from(t)),this._alg=e,this._key=t,t.length>o?t=e(t):t.length<o&&(t=n.concat([t,s],o));for(var r=this._ipad=n.allocUnsafe(o),i=this._opad=n.allocUnsafe(o),c=0;c<o;c++)r[c]=54^t[c],i[c]=92^t[c];this._hash=[r]}i(c,a),c.prototype._update=function(e){this._hash.push(e)},c.prototype._final=function(){var e=this._alg(n.concat(this._hash));return this._alg(n.concat([this._opad,e]))},t.exports=c},{"cipher-base":95,inherits:174,"safe-buffer":284}],103:[function(e,t,r){"use strict";r.randomBytes=r.rng=r.pseudoRandomBytes=r.prng=e("randombytes"),r.createHash=r.Hash=e("create-hash"),r.createHmac=r.Hmac=e("create-hmac");var i=e("browserify-sign/algos"),n=Object.keys(i),a=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(n);r.getHashes=function(){return a};var s=e("pbkdf2");r.pbkdf2=s.pbkdf2,r.pbkdf2Sync=s.pbkdf2Sync;var o=e("browserify-cipher");r.Cipher=o.Cipher,r.createCipher=o.createCipher,r.Cipheriv=o.Cipheriv,r.createCipheriv=o.createCipheriv,r.Decipher=o.Decipher,r.createDecipher=o.createDecipher,r.Decipheriv=o.Decipheriv,r.createDecipheriv=o.createDecipheriv,r.getCiphers=o.getCiphers,r.listCiphers=o.listCiphers;var c=e("diffie-hellman");r.DiffieHellmanGroup=c.DiffieHellmanGroup,r.createDiffieHellmanGroup=c.createDiffieHellmanGroup,r.getDiffieHellman=c.getDiffieHellman,r.createDiffieHellman=c.createDiffieHellman,r.DiffieHellman=c.DiffieHellman;var d=e("browserify-sign");r.createSign=d.createSign,r.Sign=d.Sign,r.createVerify=d.createVerify,r.Verify=d.Verify,r.createECDH=e("create-ecdh");var u=e("public-encrypt");r.publicEncrypt=u.publicEncrypt,r.privateEncrypt=u.privateEncrypt,r.publicDecrypt=u.publicDecrypt,r.privateDecrypt=u.privateDecrypt;var l=e("randomfill");r.randomFill=l.randomFill,r.randomFillSync=l.randomFillSync,r.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},r.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},{"browserify-cipher":81,"browserify-sign":88,"browserify-sign/algos":85,"create-ecdh":97,"create-hash":99,"create-hmac":101,"diffie-hellman":112,pbkdf2:248,"public-encrypt":258,randombytes:266,randomfill:267}],104:[function(e,t,r){(function(i){(function(){r.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let i=0,n=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(i++,"%c"===e&&(n=i))})),e.splice(n,0,r)},r.save=function(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}},r.load=function(){let e;try{e=r.storage.getItem("debug")}catch(e){}!e&&void 0!==i&&"env"in i&&(e=i.env.DEBUG);return e},r.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+)/)},r.storage=function(){try{return localStorage}catch(e){}}(),r.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`."))}})(),r.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"],r.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(r);const{formatters:n}=t.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":105,_process:257}],105:[function(e,t,r){t.exports=function(t){function r(e){let t,n,a,s=null;function o(...e){if(!o.enabled)return;const i=o,n=Number(new Date),a=n-(t||n);i.diff=a,i.prev=t,i.curr=n,t=n,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,n)=>{if("%%"===t)return"%";s++;const a=r.formatters[n];if("function"==typeof a){const r=e[s];t=a.call(i,r),e.splice(s,1),s--}return t})),r.formatArgs.call(i,e);(i.log||r.log).apply(i,e)}return o.namespace=e,o.useColors=r.useColors(),o.color=r.selectColor(e),o.extend=i,o.destroy=r.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(n!==r.namespaces&&(n=r.namespaces,a=r.enabled(e)),a),set:e=>{s=e}}),"function"==typeof r.init&&r.init(o),o}function i(e,t){const i=r(this.namespace+(void 0===t?":":t)+e);return i.log=this.log,i}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},r.disable=function(){const e=[...r.names.map(n),...r.skips.map(n).map((e=>"-"+e))].join(",");return r.enable(""),e},r.enable=function(e){let t;r.save(e),r.namespaces=e,r.names=[],r.skips=[];const i=("string"==typeof e?e:"").split(/[\s,]+/),n=i.length;for(t=0;t<n;t++)i[t]&&("-"===(e=i[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.slice(1)+"$")):r.names.push(new RegExp("^"+e+"$")))},r.enabled=function(e){if("*"===e[e.length-1])return!0;let t,i;for(t=0,i=r.skips.length;t<i;t++)if(r.skips[t].test(e))return!1;for(t=0,i=r.names.length;t<i;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=e("ms"),r.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(t).forEach((e=>{r[e]=t[e]})),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return r.colors[Math.abs(t)%r.colors.length]},r.enable(r.load()),r}},{ms:241}],106:[function(e,t,r){"use strict";r.utils=e("./des/utils"),r.Cipher=e("./des/cipher"),r.DES=e("./des/des"),r.CBC=e("./des/cbc"),r.EDE=e("./des/ede")},{"./des/cbc":107,"./des/cipher":108,"./des/des":109,"./des/ede":110,"./des/utils":111}],107:[function(e,t,r){"use strict";var i=e("minimalistic-assert"),n=e("inherits"),a={};function s(e){i.equal(e.length,8,"Invalid IV length"),this.iv=new Array(8);for(var t=0;t<this.iv.length;t++)this.iv[t]=e[t]}r.instantiate=function(e){function t(t){e.call(this,t),this._cbcInit()}n(t,e);for(var r=Object.keys(a),i=0;i<r.length;i++){var s=r[i];t.prototype[s]=a[s]}return t.create=function(e){return new t(e)},t},a._cbcInit=function(){var e=new s(this.options.iv);this._cbcState=e},a._update=function(e,t,r,i){var n=this._cbcState,a=this.constructor.super_.prototype,s=n.iv;if("encrypt"===this.type){for(var o=0;o<this.blockSize;o++)s[o]^=e[t+o];a._update.call(this,s,0,r,i);for(o=0;o<this.blockSize;o++)s[o]=r[i+o]}else{a._update.call(this,e,t,r,i);for(o=0;o<this.blockSize;o++)r[i+o]^=s[o];for(o=0;o<this.blockSize;o++)s[o]=e[t+o]}}},{inherits:174,"minimalistic-assert":239}],108:[function(e,t,r){"use strict";var i=e("minimalistic-assert");function n(e){this.options=e,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0,this.padding=!1!==e.padding}t.exports=n,n.prototype._init=function(){},n.prototype.update=function(e){return 0===e.length?[]:"decrypt"===this.type?this._updateDecrypt(e):this._updateEncrypt(e)},n.prototype._buffer=function(e,t){for(var r=Math.min(this.buffer.length-this.bufferOff,e.length-t),i=0;i<r;i++)this.buffer[this.bufferOff+i]=e[t+i];return this.bufferOff+=r,r},n.prototype._flushBuffer=function(e,t){return this._update(this.buffer,0,e,t),this.bufferOff=0,this.blockSize},n.prototype._updateEncrypt=function(e){var t=0,r=0,i=(this.bufferOff+e.length)/this.blockSize|0,n=new Array(i*this.blockSize);0!==this.bufferOff&&(t+=this._buffer(e,t),this.bufferOff===this.buffer.length&&(r+=this._flushBuffer(n,r)));for(var a=e.length-(e.length-t)%this.blockSize;t<a;t+=this.blockSize)this._update(e,t,n,r),r+=this.blockSize;for(;t<e.length;t++,this.bufferOff++)this.buffer[this.bufferOff]=e[t];return n},n.prototype._updateDecrypt=function(e){for(var t=0,r=0,i=Math.ceil((this.bufferOff+e.length)/this.blockSize)-1,n=new Array(i*this.blockSize);i>0;i--)t+=this._buffer(e,t),r+=this._flushBuffer(n,r);return t+=this._buffer(e,t),n},n.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},n.prototype._pad=function(e,t){if(0===t)return!1;for(;t<e.length;)e[t++]=0;return!0},n.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var e=new Array(this.blockSize);return this._update(this.buffer,0,e,0),e},n.prototype._unpad=function(e){return e},n.prototype._finalDecrypt=function(){i.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var e=new Array(this.blockSize);return this._flushBuffer(e,0),this._unpad(e)}},{"minimalistic-assert":239}],109:[function(e,t,r){"use strict";var i=e("minimalistic-assert"),n=e("inherits"),a=e("./utils"),s=e("./cipher");function o(){this.tmp=new Array(2),this.keys=null}function c(e){s.call(this,e);var t=new o;this._desState=t,this.deriveKeys(t,e.key)}n(c,s),t.exports=c,c.create=function(e){return new c(e)};var d=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];c.prototype.deriveKeys=function(e,t){e.keys=new Array(32),i.equal(t.length,this.blockSize,"Invalid key length");var r=a.readUInt32BE(t,0),n=a.readUInt32BE(t,4);a.pc1(r,n,e.tmp,0),r=e.tmp[0],n=e.tmp[1];for(var s=0;s<e.keys.length;s+=2){var o=d[s>>>1];r=a.r28shl(r,o),n=a.r28shl(n,o),a.pc2(r,n,e.keys,s)}},c.prototype._update=function(e,t,r,i){var n=this._desState,s=a.readUInt32BE(e,t),o=a.readUInt32BE(e,t+4);a.ip(s,o,n.tmp,0),s=n.tmp[0],o=n.tmp[1],"encrypt"===this.type?this._encrypt(n,s,o,n.tmp,0):this._decrypt(n,s,o,n.tmp,0),s=n.tmp[0],o=n.tmp[1],a.writeUInt32BE(r,s,i),a.writeUInt32BE(r,o,i+4)},c.prototype._pad=function(e,t){if(!1===this.padding)return!1;for(var r=e.length-t,i=t;i<e.length;i++)e[i]=r;return!0},c.prototype._unpad=function(e){if(!1===this.padding)return e;for(var t=e[e.length-1],r=e.length-t;r<e.length;r++)i.equal(e[r],t);return e.slice(0,e.length-t)},c.prototype._encrypt=function(e,t,r,i,n){for(var s=t,o=r,c=0;c<e.keys.length;c+=2){var d=e.keys[c],u=e.keys[c+1];a.expand(o,e.tmp,0),d^=e.tmp[0],u^=e.tmp[1];var l=a.substitute(d,u),h=o;o=(s^a.permute(l))>>>0,s=h}a.rip(o,s,i,n)},c.prototype._decrypt=function(e,t,r,i,n){for(var s=r,o=t,c=e.keys.length-2;c>=0;c-=2){var d=e.keys[c],u=e.keys[c+1];a.expand(s,e.tmp,0),d^=e.tmp[0],u^=e.tmp[1];var l=a.substitute(d,u),h=s;s=(o^a.permute(l))>>>0,o=h}a.rip(s,o,i,n)}},{"./cipher":108,"./utils":111,inherits:174,"minimalistic-assert":239}],110:[function(e,t,r){"use strict";var i=e("minimalistic-assert"),n=e("inherits"),a=e("./cipher"),s=e("./des");function o(e,t){i.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),n=t.slice(8,16),a=t.slice(16,24);this.ciphers="encrypt"===e?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:n}),s.create({type:"encrypt",key:a})]:[s.create({type:"decrypt",key:a}),s.create({type:"encrypt",key:n}),s.create({type:"decrypt",key:r})]}function c(e){a.call(this,e);var t=new o(this.type,this.options.key);this._edeState=t}n(c,a),t.exports=c,c.create=function(e){return new c(e)},c.prototype._update=function(e,t,r,i){var n=this._edeState;n.ciphers[0]._update(e,t,r,i),n.ciphers[1]._update(r,i,r,i),n.ciphers[2]._update(r,i,r,i)},c.prototype._pad=s.prototype._pad,c.prototype._unpad=s.prototype._unpad},{"./cipher":108,"./des":109,inherits:174,"minimalistic-assert":239}],111:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,i){for(var n=0,a=0,s=6;s>=0;s-=2){for(var o=0;o<=24;o+=8)n<<=1,n|=t>>>o+s&1;for(o=0;o<=24;o+=8)n<<=1,n|=e>>>o+s&1}for(s=6;s>=0;s-=2){for(o=1;o<=25;o+=8)a<<=1,a|=t>>>o+s&1;for(o=1;o<=25;o+=8)a<<=1,a|=e>>>o+s&1}r[i+0]=n>>>0,r[i+1]=a>>>0},r.rip=function(e,t,r,i){for(var n=0,a=0,s=0;s<4;s++)for(var o=24;o>=0;o-=8)n<<=1,n|=t>>>o+s&1,n<<=1,n|=e>>>o+s&1;for(s=4;s<8;s++)for(o=24;o>=0;o-=8)a<<=1,a|=t>>>o+s&1,a<<=1,a|=e>>>o+s&1;r[i+0]=n>>>0,r[i+1]=a>>>0},r.pc1=function(e,t,r,i){for(var n=0,a=0,s=7;s>=5;s--){for(var o=0;o<=24;o+=8)n<<=1,n|=t>>o+s&1;for(o=0;o<=24;o+=8)n<<=1,n|=e>>o+s&1}for(o=0;o<=24;o+=8)n<<=1,n|=t>>o+s&1;for(s=1;s<=3;s++){for(o=0;o<=24;o+=8)a<<=1,a|=t>>o+s&1;for(o=0;o<=24;o+=8)a<<=1,a|=e>>o+s&1}for(o=0;o<=24;o+=8)a<<=1,a|=e>>o+s&1;r[i+0]=n>>>0,r[i+1]=a>>>0},r.r28shl=function(e,t){return e<<t&268435455|e>>>28-t};var i=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,n){for(var a=0,s=0,o=i.length>>>1,c=0;c<o;c++)a<<=1,a|=e>>>i[c]&1;for(c=o;c<i.length;c++)s<<=1,s|=t>>>i[c]&1;r[n+0]=a>>>0,r[n+1]=s>>>0},r.expand=function(e,t,r){var i=0,n=0;i=(1&e)<<5|e>>>27;for(var a=23;a>=15;a-=4)i<<=6,i|=e>>>a&63;for(a=11;a>=3;a-=4)n|=e>>>a&63,n<<=6;n|=(31&e)<<1|e>>>31,t[r+0]=i>>>0,t[r+1]=n>>>0};var n=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,i=0;i<4;i++){r<<=4,r|=n[64*i+(e>>>18-6*i&63)]}for(i=0;i<4;i++){r<<=4,r|=n[256+64*i+(t>>>18-6*i&63)]}return r>>>0};var a=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r<a.length;r++)t<<=1,t|=e>>>a[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var i=e.toString(2);i.length<t;)i="0"+i;for(var n=[],a=0;a<t;a+=r)n.push(i.slice(a,a+r));return n.join(" ")}},{}],112:[function(e,t,r){(function(t){(function(){var i=e("./lib/generatePrime"),n=e("./lib/primes.json"),a=e("./lib/dh");var s={binary:!0,hex:!0,base64:!0};r.DiffieHellmanGroup=r.createDiffieHellmanGroup=r.getDiffieHellman=function(e){var r=new t(n[e].prime,"hex"),i=new t(n[e].gen,"hex");return new a(r,i)},r.createDiffieHellman=r.DiffieHellman=function e(r,n,o,c){return t.isBuffer(n)||void 0===s[n]?e(r,"binary",n,o):(n=n||"binary",c=c||"binary",o=o||new t([2]),t.isBuffer(o)||(o=new t(o,c)),"number"==typeof r?new a(i(r,o),o,!0):(t.isBuffer(r)||(r=new t(r,n)),new a(r,o,!0)))}}).call(this)}).call(this,e("buffer").Buffer)},{"./lib/dh":113,"./lib/generatePrime":114,"./lib/primes.json":115,buffer:94}],113:[function(e,t,r){(function(r){(function(){var i=e("bn.js"),n=new(e("miller-rabin")),a=new i(24),s=new i(11),o=new i(10),c=new i(3),d=new i(7),u=e("./generatePrime"),l=e("randombytes");function h(e,t){return t=t||"utf8",r.isBuffer(e)||(e=new r(e,t)),this._pub=new i(e),this}function f(e,t){return t=t||"utf8",r.isBuffer(e)||(e=new r(e,t)),this._priv=new i(e),this}t.exports=m;var p={};function m(e,t,r){this.setGenerator(t),this.__prime=new i(e),this._prime=i.mont(this.__prime),this._primeLen=e.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,r?(this.setPublicKey=h,this.setPrivateKey=f):this._primeCode=8}function b(e,t){var i=new r(e.toArray());return t?i.toString(t):i}Object.defineProperty(m.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=function(e,t){var r=t.toString("hex"),i=[r,e.toString(16)].join("_");if(i in p)return p[i];var l,h=0;if(e.isEven()||!u.simpleSieve||!u.fermatTest(e)||!n.test(e))return h+=1,h+="02"===r||"05"===r?8:4,p[i]=h,h;switch(n.test(e.shrn(1))||(h+=2),r){case"02":e.mod(a).cmp(s)&&(h+=8);break;case"05":(l=e.mod(o)).cmp(c)&&l.cmp(d)&&(h+=8);break;default:h+=4}return p[i]=h,h}(this.__prime,this.__gen)),this._primeCode}}),m.prototype.generateKeys=function(){return this._priv||(this._priv=new i(l(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},m.prototype.computeSecret=function(e){var t=(e=(e=new i(e)).toRed(this._prime)).redPow(this._priv).fromRed(),n=new r(t.toArray()),a=this.getPrime();if(n.length<a.length){var s=new r(a.length-n.length);s.fill(0),n=r.concat([s,n])}return n},m.prototype.getPublicKey=function(e){return b(this._pub,e)},m.prototype.getPrivateKey=function(e){return b(this._priv,e)},m.prototype.getPrime=function(e){return b(this.__prime,e)},m.prototype.getGenerator=function(e){return b(this._gen,e)},m.prototype.setGenerator=function(e,t){return t=t||"utf8",r.isBuffer(e)||(e=new r(e,t)),this.__gen=e,this._gen=new i(e),this}}).call(this)}).call(this,e("buffer").Buffer)},{"./generatePrime":114,"bn.js":116,buffer:94,"miller-rabin":237,randombytes:266}],114:[function(e,t,r){var i=e("randombytes");t.exports=v,v.simpleSieve=b,v.fermatTest=g;var n=e("bn.js"),a=new n(24),s=new(e("miller-rabin")),o=new n(1),c=new n(2),d=new n(5),u=(new n(16),new n(8),new n(10)),l=new n(3),h=(new n(7),new n(11)),f=new n(4),p=(new n(12),null);function m(){if(null!==p)return p;var e=[];e[0]=2;for(var t=1,r=3;r<1048576;r+=2){for(var i=Math.ceil(Math.sqrt(r)),n=0;n<t&&e[n]<=i&&r%e[n]!=0;n++);t!==n&&e[n]<=i||(e[t++]=r)}return p=e,e}function b(e){for(var t=m(),r=0;r<t.length;r++)if(0===e.modn(t[r]))return 0===e.cmpn(t[r]);return!0}function g(e){var t=n.mont(e);return 0===c.toRed(t).redPow(e.subn(1)).fromRed().cmpn(1)}function v(e,t){if(e<16)return new n(2===t||5===t?[140,123]:[140,39]);var r,p;for(t=new n(t);;){for(r=new n(i(Math.ceil(e/8)));r.bitLength()>e;)r.ishrn(1);if(r.isEven()&&r.iadd(o),r.testn(1)||r.iadd(c),t.cmp(c)){if(!t.cmp(d))for(;r.mod(u).cmp(l);)r.iadd(f)}else for(;r.mod(a).cmp(h);)r.iadd(f);if(b(p=r.shrn(1))&&b(r)&&g(p)&&g(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":116,"miller-rabin":237,randombytes:266}],115:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],116:[function(e,t,r){arguments[4][55][0].apply(r,arguments)},{buffer:63,dup:55}],117:[function(e,t,r){"use strict";var i=e("safe-buffer").Buffer,n=e("./param-bytes-for-alg"),a=128;function s(e){if(i.isBuffer(e))return e;if("string"==typeof e)return i.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function o(e,t,r){for(var i=0;t+i<r&&0===e[t+i];)++i;return e[t+i]>=a&&--i,i}t.exports={derToJose:function(e,t){e=s(e);var r=n(t),o=r+1,c=e.length,d=0;if(48!==e[d++])throw new Error('Could not find expected "seq"');var u=e[d++];if(u===(1|a)&&(u=e[d++]),c-d<u)throw new Error('"seq" specified length of "'+u+'", only "'+(c-d)+'" remaining');if(2!==e[d++])throw new Error('Could not find expected "int" for "r"');var l=e[d++];if(c-d-2<l)throw new Error('"r" specified length of "'+l+'", only "'+(c-d-2)+'" available');if(o<l)throw new Error('"r" specified length of "'+l+'", max of "'+o+'" is acceptable');var h=d;if(d+=l,2!==e[d++])throw new Error('Could not find expected "int" for "s"');var f=e[d++];if(c-d!==f)throw new Error('"s" specified length of "'+f+'", expected "'+(c-d)+'"');if(o<f)throw new Error('"s" specified length of "'+f+'", max of "'+o+'" is acceptable');var p=d;if((d+=f)!==c)throw new Error('Expected to consume entire buffer, but "'+(c-d)+'" bytes remain');var m=r-l,b=r-f,g=i.allocUnsafe(m+l+b+f);for(d=0;d<m;++d)g[d]=0;e.copy(g,d,h+Math.max(-m,0),h+l);for(var v=d=r;d<v+b;++d)g[d]=0;return e.copy(g,d,p+Math.max(-b,0),p+f),g=(g=g.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(e,t){e=s(e);var r=n(t),c=e.length;if(c!==2*r)throw new TypeError('"'+t+'" signatures must be "'+2*r+'" bytes, saw "'+c+'"');var d=o(e,0,r),u=o(e,r,e.length),l=r-d,h=r-u,f=2+l+1+1+h,p=f<a,m=i.allocUnsafe((p?2:3)+f),b=0;return m[b++]=48,p?m[b++]=f:(m[b++]=1|a,m[b++]=255&f),m[b++]=2,m[b++]=l,d<0?(m[b++]=0,b+=e.copy(m,b,0,r)):b+=e.copy(m,b,d,r),m[b++]=2,m[b++]=h,u<0?(m[b++]=0,e.copy(m,b,r)):e.copy(m,b,r+u),m}}},{"./param-bytes-for-alg":118,"safe-buffer":284}],118:[function(e,t,r){"use strict";function i(e){return(e/8|0)+(e%8==0?0:1)}var n={ES256:i(256),ES384:i(384),ES512:i(521)};t.exports=function(e){var t=n[e];if(t)return t;throw new Error('Unknown algorithm "'+e+'"')}},{}],119:[function(e,t,r){"use strict";var i=r;i.version=e("../package.json").version,i.utils=e("./elliptic/utils"),i.rand=e("brorand"),i.curve=e("./elliptic/curve"),i.curves=e("./elliptic/curves"),i.ec=e("./elliptic/ec"),i.eddsa=e("./elliptic/eddsa")},{"../package.json":135,"./elliptic/curve":122,"./elliptic/curves":125,"./elliptic/ec":126,"./elliptic/eddsa":129,"./elliptic/utils":133,brorand:62}],120:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../utils"),a=n.getNAF,s=n.getJSF,o=n.assert;function c(e,t){this.type=e,this.p=new i(t.p,16),this.red=t.prime?i.red(t.prime):i.mont(this.p),this.zero=new i(0).toRed(this.red),this.one=new i(1).toRed(this.red),this.two=new i(2).toRed(this.red),this.n=t.n&&new i(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function d(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){o(e.precomputed);var r=e._getDoubles(),i=a(t,1,this._bitLength),n=(1<<r.step+1)-(r.step%2==0?2:1);n/=3;var s,c,d=[];for(s=0;s<i.length;s+=r.step){c=0;for(var u=s+r.step-1;u>=s;u--)c=(c<<1)+i[u];d.push(c)}for(var l=this.jpoint(null,null,null),h=this.jpoint(null,null,null),f=n;f>0;f--){for(s=0;s<d.length;s++)(c=d[s])===f?h=h.mixedAdd(r.points[s]):c===-f&&(h=h.mixedAdd(r.points[s].neg()));l=l.add(h)}return l.toP()},c.prototype._wnafMul=function(e,t){var r=4,i=e._getNAFPoints(r);r=i.wnd;for(var n=i.points,s=a(t,r,this._bitLength),c=this.jpoint(null,null,null),d=s.length-1;d>=0;d--){for(var u=0;d>=0&&0===s[d];d--)u++;if(d>=0&&u++,c=c.dblp(u),d<0)break;var l=s[d];o(0!==l),c="affine"===e.type?l>0?c.mixedAdd(n[l-1>>1]):c.mixedAdd(n[-l-1>>1].neg()):l>0?c.add(n[l-1>>1]):c.add(n[-l-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,r,i,n){var o,c,d,u=this._wnafT1,l=this._wnafT2,h=this._wnafT3,f=0;for(o=0;o<i;o++){var p=(d=t[o])._getNAFPoints(e);u[o]=p.wnd,l[o]=p.points}for(o=i-1;o>=1;o-=2){var m=o-1,b=o;if(1===u[m]&&1===u[b]){var g=[t[m],null,null,t[b]];0===t[m].y.cmp(t[b].y)?(g[1]=t[m].add(t[b]),g[2]=t[m].toJ().mixedAdd(t[b].neg())):0===t[m].y.cmp(t[b].y.redNeg())?(g[1]=t[m].toJ().mixedAdd(t[b]),g[2]=t[m].add(t[b].neg())):(g[1]=t[m].toJ().mixedAdd(t[b]),g[2]=t[m].toJ().mixedAdd(t[b].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],y=s(r[m],r[b]);for(f=Math.max(y[0].length,f),h[m]=new Array(f),h[b]=new Array(f),c=0;c<f;c++){var _=0|y[0][c],w=0|y[1][c];h[m][c]=v[3*(_+1)+(w+1)],h[b][c]=0,l[m]=g}}else h[m]=a(r[m],u[m],this._bitLength),h[b]=a(r[b],u[b],this._bitLength),f=Math.max(h[m].length,f),f=Math.max(h[b].length,f)}var S=this.jpoint(null,null,null),k=this._wnafT4;for(o=f;o>=0;o--){for(var R=0;o>=0;){var P=!0;for(c=0;c<i;c++)k[c]=0|h[c][o],0!==k[c]&&(P=!1);if(!P)break;R++,o--}if(o>=0&&R++,S=S.dblp(R),o<0)break;for(c=0;c<i;c++){var M=k[c];0!==M&&(M>0?d=l[c][M-1>>1]:M<0&&(d=l[c][-M-1>>1].neg()),S="affine"===d.type?S.mixedAdd(d):S.add(d))}}for(o=0;o<i;o++)l[o]=null;return n?S:S.toP()},c.BasePoint=d,d.prototype.eq=function(){throw new Error("Not implemented")},d.prototype.validate=function(){return this.curve.validate(this)},c.prototype.decodePoint=function(e,t){e=n.toArray(e,t);var r=this.p.byteLength();if((4===e[0]||6===e[0]||7===e[0])&&e.length-1==2*r)return 6===e[0]?o(e[e.length-1]%2==0):7===e[0]&&o(e[e.length-1]%2==1),this.point(e.slice(1,1+r),e.slice(1+r,1+2*r));if((2===e[0]||3===e[0])&&e.length-1===r)return this.pointFromX(e.slice(1,1+r),3===e[0]);throw new Error("Unknown point format")},d.prototype.encodeCompressed=function(e){return this.encode(e,!0)},d.prototype._encode=function(e){var t=this.curve.p.byteLength(),r=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",t))},d.prototype.encode=function(e,t){return n.encode(this._encode(t),e)},d.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},d.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return!!t&&t.points.length>=Math.ceil((e.bitLength()+1)/t.step)},d.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<t;n+=e){for(var a=0;a<e;a++)i=i.dbl();r.push(i)}return{step:e,points:r}},d.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],r=(1<<e)-1,i=1===r?null:this.dbl(),n=1;n<r;n++)t[n]=t[n-1].add(i);return{wnd:e,points:t}},d.prototype._getBeta=function(){return null},d.prototype.dblp=function(e){for(var t=this,r=0;r<e;r++)t=t.dbl();return t}},{"../utils":133,"bn.js":134}],121:[function(e,t,r){"use strict";var i=e("../utils"),n=e("bn.js"),a=e("inherits"),s=e("./base"),o=i.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,s.call(this,"edwards",e),this.a=new n(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new n(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new n(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),o(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function d(e,t,r,i,a){s.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===i?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new n(t,16),this.y=new n(r,16),this.z=i?new n(i,16):this.curve.one,this.t=a&&new n(a,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}a(c,s),t.exports=c,c.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},c.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},c.prototype.jpoint=function(e,t,r,i){return this.point(e,t,r,i)},c.prototype.pointFromX=function(e,t){(e=new n(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),i=this.c2.redSub(this.a.redMul(r)),a=this.one.redSub(this.c2.redMul(this.d).redMul(r)),s=i.redMul(a.redInvm()),o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var c=o.fromRed().isOdd();return(t&&!c||!t&&c)&&(o=o.redNeg()),this.point(e,o)},c.prototype.pointFromY=function(e,t){(e=new n(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),i=r.redSub(this.c2),a=r.redMul(this.d).redMul(this.c2).redSub(this.a),s=i.redMul(a.redInvm());if(0===s.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");return o.fromRed().isOdd()!==t&&(o=o.redNeg()),this.point(o,e)},c.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),i=t.redMul(this.a).redAdd(r),n=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===i.cmp(n)},a(d,s.BasePoint),c.prototype.pointFromJSON=function(e){return d.fromJSON(this,e)},c.prototype.point=function(e,t,r,i){return new d(this,e,t,r,i)},d.fromJSON=function(e,t){return new d(e,t[0],t[1],t[2])},d.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},d.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},d.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(e),n=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),a=i.redAdd(t),s=a.redSub(r),o=i.redSub(t),c=n.redMul(s),d=a.redMul(o),u=n.redMul(o),l=s.redMul(a);return this.curve.point(c,d,l,u)},d.prototype._projDbl=function(){var e,t,r,i,n,a,s=this.x.redAdd(this.y).redSqr(),o=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var d=(i=this.curve._mulA(o)).redAdd(c);this.zOne?(e=s.redSub(o).redSub(c).redMul(d.redSub(this.curve.two)),t=d.redMul(i.redSub(c)),r=d.redSqr().redSub(d).redSub(d)):(n=this.z.redSqr(),a=d.redSub(n).redISub(n),e=s.redSub(o).redISub(c).redMul(a),t=d.redMul(i.redSub(c)),r=d.redMul(a))}else i=o.redAdd(c),n=this.curve._mulC(this.z).redSqr(),a=i.redSub(n).redSub(n),e=this.curve._mulC(s.redISub(i)).redMul(a),t=this.curve._mulC(i).redMul(o.redISub(c)),r=i.redMul(a);return this.curve.point(e,t,r)},d.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},d.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),n=this.z.redMul(e.z.redAdd(e.z)),a=r.redSub(t),s=n.redSub(i),o=n.redAdd(i),c=r.redAdd(t),d=a.redMul(s),u=o.redMul(c),l=a.redMul(c),h=s.redMul(o);return this.curve.point(d,u,h,l)},d.prototype._projAdd=function(e){var t,r,i=this.z.redMul(e.z),n=i.redSqr(),a=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(a).redMul(s),c=n.redSub(o),d=n.redAdd(o),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(a).redISub(s),l=i.redMul(c).redMul(u);return this.curve.twisted?(t=i.redMul(d).redMul(s.redSub(this.curve._mulA(a))),r=c.redMul(d)):(t=i.redMul(d).redMul(s.redSub(a)),r=this.curve._mulC(c).redMul(d)),this.curve.point(l,t,r)},d.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},d.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},d.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},d.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},d.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},d.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},d.prototype.getX=function(){return this.normalize(),this.x.fromRed()},d.prototype.getY=function(){return this.normalize(),this.y.fromRed()},d.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},d.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}},d.prototype.toP=d.prototype.normalize,d.prototype.mixedAdd=d.prototype.add},{"../utils":133,"./base":120,"bn.js":134,inherits:174}],122:[function(e,t,r){"use strict";var i=r;i.base=e("./base"),i.short=e("./short"),i.mont=e("./mont"),i.edwards=e("./edwards")},{"./base":120,"./edwards":121,"./mont":123,"./short":124}],123:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("inherits"),a=e("./base"),s=e("../utils");function o(e){a.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){a.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}n(o,a),t.exports=o,o.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),i=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===i.redSqrt().redSqr().cmp(i)},n(c,a.BasePoint),o.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},o.prototype.point=function(e,t){return new c(this,e,t)},o.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),i=e.redMul(t),n=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=e.x.redAdd(e.z),a=e.x.redSub(e.z).redMul(r),s=n.redMul(i),o=t.z.redMul(a.redAdd(s).redSqr()),c=t.x.redMul(a.redISub(s).redSqr());return this.curve.point(o,c)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,i=this.curve.point(null,null),n=[];0!==t.cmpn(0);t.iushrn(1))n.push(t.andln(1));for(var a=n.length-1;a>=0;a--)0===n[a]?(r=r.diffAdd(i,this),i=i.dbl()):(i=r.diffAdd(i,this),r=r.dbl());return i},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":133,"./base":120,"bn.js":134,inherits:174}],124:[function(e,t,r){"use strict";var i=e("../utils"),n=e("bn.js"),a=e("inherits"),s=e("./base"),o=i.assert;function c(e){s.call(this,"short",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function d(e,t,r,i){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new n(t,16),this.y=new n(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function u(e,t,r,i){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new n(0)):(this.x=new n(t,16),this.y=new n(r,16),this.z=new n(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}a(c,s),t.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new n(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);t=(t=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(e.lambda)r=new n(e.lambda,16);else{var a=this._getEndoRoots(this.n);0===this.g.mul(a[0]).x.cmp(this.g.x.redMul(t))?r=a[0]:(r=a[1],o(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map((function(e){return{a:new n(e.a,16),b:new n(e.b,16)}})):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:n.mont(e),r=new n(2).toRed(t).redInvm(),i=r.redNeg(),a=new n(3).toRed(t).redNeg().redSqrt().redMul(r);return[i.redAdd(a).fromRed(),i.redSub(a).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,i,a,s,o,c,d,u,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),h=e,f=this.n.clone(),p=new n(1),m=new n(0),b=new n(0),g=new n(1),v=0;0!==h.cmpn(0);){var y=f.div(h);d=f.sub(y.mul(h)),u=b.sub(y.mul(p));var _=g.sub(y.mul(m));if(!i&&d.cmp(l)<0)t=c.neg(),r=p,i=d.neg(),a=u;else if(i&&2==++v)break;c=d,f=h,h=d,b=p,p=u,g=m,m=_}s=d.neg(),o=u;var w=i.sqr().add(a.sqr());return s.sqr().add(o.sqr()).cmp(w)>=0&&(s=t,o=r),i.negative&&(i=i.neg(),a=a.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:i,b:a},{a:s,b:o}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],i=t[1],n=i.b.mul(e).divRound(this.n),a=r.b.neg().mul(e).divRound(this.n),s=n.mul(r.a),o=a.mul(i.a),c=n.mul(r.b),d=a.mul(i.b);return{k1:e.sub(s).sub(o),k2:c.add(d).neg()}},c.prototype.pointFromX=function(e,t){(e=new n(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var a=i.fromRed().isOdd();return(t&&!a||!t&&a)&&(i=i.redNeg()),this.point(e,i)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,i=this.a.redMul(t),n=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,a=0;a<e.length;a++){var s=this._endoSplit(t[a]),o=e[a],c=o._getBeta();s.k1.negative&&(s.k1.ineg(),o=o.neg(!0)),s.k2.negative&&(s.k2.ineg(),c=c.neg(!0)),i[2*a]=o,i[2*a+1]=c,n[2*a]=s.k1,n[2*a+1]=s.k2}for(var d=this._wnafMulAdd(1,i,n,2*a,r),u=0;u<2*a;u++)i[u]=null,n[u]=null;return d},a(d,s.BasePoint),c.prototype.point=function(e,t,r){return new d(this,e,t,r)},c.prototype.pointFromJSON=function(e,t){return d.fromJSON(this,e,t)},d.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var r=this.curve,i=function(e){return r.point(e.x.redMul(r.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(i)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(i)}}}return t}},d.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},d.fromJSON=function(e,t,r){"string"==typeof t&&(t=JSON.parse(t));var i=e.point(t[0],t[1],r);if(!t[2])return i;function n(t){return e.point(t[0],t[1],r)}var a=t[2];return i.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[i].concat(a.doubles.points.map(n))},naf:a.naf&&{wnd:a.naf.wnd,points:[i].concat(a.naf.points.map(n))}},i},d.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},d.prototype.isInfinity=function(){return this.inf},d.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},d.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),i=e.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(i),a=n.redSqr().redISub(this.x.redAdd(this.x)),s=n.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,s)},d.prototype.getX=function(){return this.x.fromRed()},d.prototype.getY=function(){return this.y.fromRed()},d.prototype.mul=function(e){return e=new n(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},d.prototype.mulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},d.prototype.jmulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},d.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},d.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return t},d.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},a(u,s.BasePoint),c.prototype.jpoint=function(e,t,r){return new u(this,e,t,r)},u.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(r,i)},u.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},u.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(t),n=e.x.redMul(r),a=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),o=i.redSub(n),c=a.redSub(s);if(0===o.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var d=o.redSqr(),u=d.redMul(o),l=i.redMul(d),h=c.redSqr().redIAdd(u).redISub(l).redISub(l),f=c.redMul(l.redISub(h)).redISub(a.redMul(u)),p=this.z.redMul(e.z).redMul(o);return this.curve.jpoint(h,f,p)},u.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,i=e.x.redMul(t),n=this.y,a=e.y.redMul(t).redMul(this.z),s=r.redSub(i),o=n.redSub(a);if(0===s.cmpn(0))return 0!==o.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),d=c.redMul(s),u=r.redMul(c),l=o.redSqr().redIAdd(d).redISub(u).redISub(u),h=o.redMul(u.redISub(l)).redISub(n.redMul(d)),f=this.z.redMul(s);return this.curve.jpoint(l,h,f)},u.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t<e;t++)r=r.dbl();return r}var i=this.curve.a,n=this.curve.tinv,a=this.x,s=this.y,o=this.z,c=o.redSqr().redSqr(),d=s.redAdd(s);for(t=0;t<e;t++){var u=a.redSqr(),l=d.redSqr(),h=l.redSqr(),f=u.redAdd(u).redIAdd(u).redIAdd(i.redMul(c)),p=a.redMul(l),m=f.redSqr().redISub(p.redAdd(p)),b=p.redISub(m),g=f.redMul(b);g=g.redIAdd(g).redISub(h);var v=d.redMul(o);t+1<e&&(c=c.redMul(h)),a=m,o=v,d=g}return this.curve.jpoint(a,d.redMul(n),o)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},u.prototype._zeroDbl=function(){var e,t,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),a=n.redSqr(),s=this.x.redAdd(n).redSqr().redISub(i).redISub(a);s=s.redIAdd(s);var o=i.redAdd(i).redIAdd(i),c=o.redSqr().redISub(s).redISub(s),d=a.redIAdd(a);d=(d=d.redIAdd(d)).redIAdd(d),e=c,t=o.redMul(s.redISub(c)).redISub(d),r=this.y.redAdd(this.y)}else{var u=this.x.redSqr(),l=this.y.redSqr(),h=l.redSqr(),f=this.x.redAdd(l).redSqr().redISub(u).redISub(h);f=f.redIAdd(f);var p=u.redAdd(u).redIAdd(u),m=p.redSqr(),b=h.redIAdd(h);b=(b=b.redIAdd(b)).redIAdd(b),e=m.redISub(f).redISub(f),t=p.redMul(f.redISub(e)).redISub(b),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(e,t,r)},u.prototype._threeDbl=function(){var e,t,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),a=n.redSqr(),s=this.x.redAdd(n).redSqr().redISub(i).redISub(a);s=s.redIAdd(s);var o=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),c=o.redSqr().redISub(s).redISub(s);e=c;var d=a.redIAdd(a);d=(d=d.redIAdd(d)).redIAdd(d),t=o.redMul(s.redISub(c)).redISub(d),r=this.y.redAdd(this.y)}else{var u=this.z.redSqr(),l=this.y.redSqr(),h=this.x.redMul(l),f=this.x.redSub(u).redMul(this.x.redAdd(u));f=f.redAdd(f).redIAdd(f);var p=h.redIAdd(h),m=(p=p.redIAdd(p)).redAdd(p);e=f.redSqr().redISub(m),r=this.y.redAdd(this.z).redSqr().redISub(l).redISub(u);var b=l.redSqr();b=(b=(b=b.redIAdd(b)).redIAdd(b)).redIAdd(b),t=f.redMul(p.redISub(e)).redISub(b)}return this.curve.jpoint(e,t,r)},u.prototype._dbl=function(){var e=this.curve.a,t=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),a=t.redSqr(),s=r.redSqr(),o=a.redAdd(a).redIAdd(a).redIAdd(e.redMul(n)),c=t.redAdd(t),d=(c=c.redIAdd(c)).redMul(s),u=o.redSqr().redISub(d.redAdd(d)),l=d.redISub(u),h=s.redSqr();h=(h=(h=h.redIAdd(h)).redIAdd(h)).redIAdd(h);var f=o.redMul(l).redISub(h),p=r.redAdd(r).redMul(i);return this.curve.jpoint(u,f,p)},u.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr(),i=t.redSqr(),n=e.redAdd(e).redIAdd(e),a=n.redSqr(),s=this.x.redAdd(t).redSqr().redISub(e).redISub(i),o=(s=(s=(s=s.redIAdd(s)).redAdd(s).redIAdd(s)).redISub(a)).redSqr(),c=i.redIAdd(i);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=n.redIAdd(s).redSqr().redISub(a).redISub(o).redISub(c),u=t.redMul(d);u=(u=u.redIAdd(u)).redIAdd(u);var l=this.x.redMul(o).redISub(u);l=(l=l.redIAdd(l)).redIAdd(l);var h=this.y.redMul(d.redMul(c.redISub(d)).redISub(s.redMul(o)));h=(h=(h=h.redIAdd(h)).redIAdd(h)).redIAdd(h);var f=this.z.redAdd(s).redSqr().redISub(r).redISub(o);return this.curve.jpoint(l,h,f)},u.prototype.mul=function(e,t){return e=new n(e,t),this.curve._wnafMul(this,e)},u.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),r=e.z.redSqr();if(0!==this.x.redMul(r).redISub(e.x.redMul(t)).cmpn(0))return!1;var i=t.redMul(this.z),n=r.redMul(e.z);return 0===this.y.redMul(n).redISub(e.y.redMul(i)).cmpn(0)},u.prototype.eqXToP=function(e){var t=this.z.redSqr(),r=e.toRed(this.curve.red).redMul(t);if(0===this.x.cmp(r))return!0;for(var i=e.clone(),n=this.curve.redN.redMul(t);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},u.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":133,"./base":120,"bn.js":134,inherits:174}],125:[function(e,t,r){"use strict";var i,n=r,a=e("hash.js"),s=e("./curve"),o=e("./utils").assert;function c(e){"short"===e.type?this.curve=new s.short(e):"edwards"===e.type?this.curve=new s.edwards(e):this.curve=new s.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,o(this.g.validate(),"Invalid curve"),o(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function d(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new c(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=c,d("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:a.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),d("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:a.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),d("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:a.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),d("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:a.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),d("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:a.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),d("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:a.sha256,gRed:!1,g:["9"]}),d("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:a.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{i=e("./precomputed/secp256k1")}catch(e){i=void 0}d("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:a.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",i]})},{"./curve":122,"./precomputed/secp256k1":132,"./utils":133,"hash.js":160}],126:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("hmac-drbg"),a=e("../utils"),s=e("../curves"),o=e("brorand"),c=a.assert,d=e("./key"),u=e("./signature");function l(e){if(!(this instanceof l))return new l(e);"string"==typeof e&&(c(Object.prototype.hasOwnProperty.call(s,e),"Unknown curve "+e),e=s[e]),e instanceof s.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=l,l.prototype.keyPair=function(e){return new d(this,e)},l.prototype.keyFromPrivate=function(e,t){return d.fromPrivate(this,e,t)},l.prototype.keyFromPublic=function(e,t){return d.fromPublic(this,e,t)},l.prototype.genKeyPair=function(e){e||(e={});for(var t=new n({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),a=this.n.sub(new i(2));;){var s=new i(t.generate(r));if(!(s.cmp(a)>0))return s.iaddn(1),this.keyFromPrivate(s)}},l.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},l.prototype.sign=function(e,t,r,a){"object"==typeof r&&(a=r,r=null),a||(a={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new i(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),c=e.toArray("be",s),d=new n({hash:this.hash,entropy:o,nonce:c,pers:a.pers,persEnc:a.persEnc||"utf8"}),l=this.n.sub(new i(1)),h=0;;h++){var f=a.k?a.k(h):new i(d.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(l)>=0)){var p=this.g.mul(f);if(!p.isInfinity()){var m=p.getX(),b=m.umod(this.n);if(0!==b.cmpn(0)){var g=f.invm(this.n).mul(b.mul(t.getPrivate()).iadd(e));if(0!==(g=g.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==m.cmp(b)?2:0);return a.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),v^=1),new u({r:b,s:g,recoveryParam:v})}}}}}},l.prototype.verify=function(e,t,r,n){e=this._truncateToN(new i(e,16)),r=this.keyFromPublic(r,n);var a=(t=new u(t,"hex")).r,s=t.s;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o,c=s.invm(this.n),d=c.mul(e).umod(this.n),l=c.mul(a).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(d,r.getPublic(),l)).isInfinity()&&o.eqXToP(a):!(o=this.g.mulAdd(d,r.getPublic(),l)).isInfinity()&&0===o.getX().umod(this.n).cmp(a)},l.prototype.recoverPubKey=function(e,t,r,n){c((3&r)===r,"The recovery param is more than two bits"),t=new u(t,n);var a=this.n,s=new i(e),o=t.r,d=t.s,l=1&r,h=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");o=h?this.curve.pointFromX(o.add(this.curve.n),l):this.curve.pointFromX(o,l);var f=t.r.invm(a),p=a.sub(s).mul(f).umod(a),m=d.mul(f).umod(a);return this.g.mulAdd(p,o,m)},l.prototype.getKeyRecoveryParam=function(e,t,r,i){if(null!==(t=new u(t,i)).recoveryParam)return t.recoveryParam;for(var n=0;n<4;n++){var a;try{a=this.recoverPubKey(e,t,n)}catch(e){continue}if(a.eq(r))return n}throw new Error("Unable to find valid recovery factor")}},{"../curves":125,"../utils":133,"./key":127,"./signature":128,"bn.js":134,brorand:62,"hmac-drbg":172}],127:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../utils").assert;function a(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=a,a.fromPublic=function(e,t,r){return t instanceof a?t:new a(e,{pub:t,pubEnc:r})},a.fromPrivate=function(e,t,r){return t instanceof a?t:new a(e,{priv:t,privEnc:r})},a.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},a.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},a.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},a.prototype._importPrivate=function(e,t){this.priv=new i(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},a.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?n(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||n(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},a.prototype.derive=function(e){return e.validate()||n(e.validate(),"public point not validated"),e.mul(this.priv).getX()},a.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},a.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},a.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},{"../utils":133,"bn.js":134}],128:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../utils"),a=n.assert;function s(e,t){if(e instanceof s)return e;this._importDER(e,t)||(a(e.r&&e.s,"Signature without r or s"),this.r=new i(e.r,16),this.s=new i(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function o(){this.place=0}function c(e,t){var r=e[t.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,a=0,s=t.place;a<i;a++,s++)n<<=8,n|=e[s],n>>>=0;return!(n<=127)&&(t.place=s,n)}function d(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t<r;)t++;return 0===t?e:e.slice(t)}function u(e,t){if(t<128)e.push(t);else{var r=1+(Math.log(t)/Math.LN2>>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=s,s.prototype._importDER=function(e,t){e=n.toArray(e,t);var r=new o;if(48!==e[r.place++])return!1;var a=c(e,r);if(!1===a)return!1;if(a+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var s=c(e,r);if(!1===s)return!1;var d=e.slice(r.place,s+r.place);if(r.place+=s,2!==e[r.place++])return!1;var u=c(e,r);if(!1===u)return!1;if(e.length!==u+r.place)return!1;var l=e.slice(r.place,u+r.place);if(0===d[0]){if(!(128&d[1]))return!1;d=d.slice(1)}if(0===l[0]){if(!(128&l[1]))return!1;l=l.slice(1)}return this.r=new i(d),this.s=new i(l),this.recoveryParam=null,!0},s.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=d(t),r=d(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];u(i,t.length),(i=i.concat(t)).push(2),u(i,r.length);var a=i.concat(r),s=[48];return u(s,a.length),s=s.concat(a),n.encode(s,e)}},{"../utils":133,"bn.js":134}],129:[function(e,t,r){"use strict";var i=e("hash.js"),n=e("../curves"),a=e("../utils"),s=a.assert,o=a.parseBytes,c=e("./key"),d=e("./signature");function u(e){if(s("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof u))return new u(e);e=n[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=i.sha512}t.exports=u,u.prototype.sign=function(e,t){e=o(e);var r=this.keyFromSecret(t),i=this.hashInt(r.messagePrefix(),e),n=this.g.mul(i),a=this.encodePoint(n),s=this.hashInt(a,r.pubBytes(),e).mul(r.priv()),c=i.add(s).umod(this.curve.n);return this.makeSignature({R:n,S:c,Rencoded:a})},u.prototype.verify=function(e,t,r){e=o(e),t=this.makeSignature(t);var i=this.keyFromPublic(r),n=this.hashInt(t.Rencoded(),i.pubBytes(),e),a=this.g.mul(t.S());return t.R().add(i.pub().mul(n)).eq(a)},u.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return a.intFromLE(e.digest()).umod(this.curve.n)},u.prototype.keyFromPublic=function(e){return c.fromPublic(this,e)},u.prototype.keyFromSecret=function(e){return c.fromSecret(this,e)},u.prototype.makeSignature=function(e){return e instanceof d?e:new d(this,e)},u.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},u.prototype.decodePoint=function(e){var t=(e=a.parseBytes(e)).length-1,r=e.slice(0,t).concat(-129&e[t]),i=!!(128&e[t]),n=a.intFromLE(r);return this.curve.pointFromY(n,i)},u.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},u.prototype.decodeInt=function(e){return a.intFromLE(e)},u.prototype.isPoint=function(e){return e instanceof this.pointClass}},{"../curves":125,"../utils":133,"./key":130,"./signature":131,"hash.js":160}],130:[function(e,t,r){"use strict";var i=e("../utils"),n=i.assert,a=i.parseBytes,s=i.cachedProperty;function o(e,t){this.eddsa=e,this._secret=a(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=a(t.pub)}o.fromPublic=function(e,t){return t instanceof o?t:new o(e,{pub:t})},o.fromSecret=function(e,t){return t instanceof o?t:new o(e,{secret:t})},o.prototype.secret=function(){return this._secret},s(o,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),s(o,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),s(o,"privBytes",(function(){var e=this.eddsa,t=this.hash(),r=e.encodingLength-1,i=t.slice(0,e.encodingLength);return i[0]&=248,i[r]&=127,i[r]|=64,i})),s(o,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),s(o,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),s(o,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),o.prototype.sign=function(e){return n(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},o.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},o.prototype.getSecret=function(e){return n(this._secret,"KeyPair is public only"),i.encode(this.secret(),e)},o.prototype.getPublic=function(e){return i.encode(this.pubBytes(),e)},t.exports=o},{"../utils":133}],131:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../utils"),a=n.assert,s=n.cachedProperty,o=n.parseBytes;function c(e,t){this.eddsa=e,"object"!=typeof t&&(t=o(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),a(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof i&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}s(c,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),s(c,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),s(c,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),s(c,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),c.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},c.prototype.toHex=function(){return n.encode(this.toBytes(),"hex").toUpperCase()},t.exports=c},{"../utils":133,"bn.js":134}],132:[function(e,t,r){t.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},{}],133:[function(e,t,r){"use strict";var i=r,n=e("bn.js"),a=e("minimalistic-assert"),s=e("minimalistic-crypto-utils");i.assert=a,i.toArray=s.toArray,i.zero2=s.zero2,i.toHex=s.toHex,i.encode=s.encode,i.getNAF=function(e,t,r){var i,n=new Array(Math.max(e.bitLength(),r)+1);for(i=0;i<n.length;i+=1)n[i]=0;var a=1<<t+1,s=e.clone();for(i=0;i<n.length;i++){var o,c=s.andln(a-1);s.isOdd()?(o=c>(a>>1)-1?(a>>1)-c:c,s.isubn(o)):o=0,n[i]=o,s.iushrn(1)}return n},i.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var i,n=0,a=0;e.cmpn(-n)>0||t.cmpn(-a)>0;){var s,o,c=e.andln(3)+n&3,d=t.andln(3)+a&3;3===c&&(c=-1),3===d&&(d=-1),s=1&c?3!==(i=e.andln(7)+n&7)&&5!==i||2!==d?c:-c:0,r[0].push(s),o=1&d?3!==(i=t.andln(7)+a&7)&&5!==i||2!==c?d:-d:0,r[1].push(o),2*n===s+1&&(n=1-n),2*a===o+1&&(a=1-a),e.iushrn(1),t.iushrn(1)}return r},i.cachedProperty=function(e,t,r){var i="_"+t;e.prototype[t]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},i.parseBytes=function(e){return"string"==typeof e?i.toArray(e,"hex"):e},i.intFromLE=function(e){return new n(e,"hex","le")}},{"bn.js":134,"minimalistic-assert":239,"minimalistic-crypto-utils":240}],134:[function(e,t,r){arguments[4][55][0].apply(r,arguments)},{buffer:63,dup:55}],135:[function(e,t,r){t.exports={name:"elliptic",version:"6.5.5",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny <fedor@indutny.com>",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}},{}],136:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasCORS=void 0;let i=!1;try{i="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}r.hasCORS=i},{}],137:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode=r.encode=void 0,r.encode=function(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t},r.decode=function(e){let t={},r=e.split("&");for(let e=0,i=r.length;e<i;e++){let i=r[e].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}},{}],138:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parse=void 0;const i=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];r.parse=function(e){if(e.length>2e3)throw"URI too long";const t=e,r=e.indexOf("["),a=e.indexOf("]");-1!=r&&-1!=a&&(e=e.substring(0,r)+e.substring(r,a).replace(/:/g,";")+e.substring(a,e.length));let s=i.exec(e||""),o={},c=14;for(;c--;)o[n[c]]=s[c]||"";return-1!=r&&-1!=a&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(e,t){const r=/\/{2,9}/g,i=t.replace(r,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||i.splice(0,1);"/"==t.slice(-1)&&i.splice(i.length-1,1);return i}(0,o.path),o.queryKey=function(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,i){t&&(r[t]=i)})),r}(0,o.query),o}},{}],139:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.yeast=r.decode=r.encode=void 0;const i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),n=64,a={};let s,o=0,c=0;function d(e){let t="";do{t=i[e%n]+t,e=Math.floor(e/n)}while(e>0);return t}for(r.encode=d,r.decode=function(e){let t=0;for(c=0;c<e.length;c++)t=t*n+a[e.charAt(c)];return t},r.yeast=function(){const e=d(+new Date);return e!==s?(o=0,s=e):e+"."+d(o++)};c<n;c++)a[i[c]]=c},{}],140:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.globalThisShim=void 0,r.globalThisShim="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()},{}],141:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.nextTick=r.parse=r.installTimerFunctions=r.transports=r.TransportError=r.Transport=r.protocol=r.Socket=void 0;const i=e("./socket.js");Object.defineProperty(r,"Socket",{enumerable:!0,get:function(){return i.Socket}}),r.protocol=i.Socket.protocol;var n=e("./transport.js");Object.defineProperty(r,"Transport",{enumerable:!0,get:function(){return n.Transport}}),Object.defineProperty(r,"TransportError",{enumerable:!0,get:function(){return n.TransportError}});var a=e("./transports/index.js");Object.defineProperty(r,"transports",{enumerable:!0,get:function(){return a.transports}});var s=e("./util.js");Object.defineProperty(r,"installTimerFunctions",{enumerable:!0,get:function(){return s.installTimerFunctions}});var o=e("./contrib/parseuri.js");Object.defineProperty(r,"parse",{enumerable:!0,get:function(){return o.parse}});var c=e("./transports/websocket-constructor.js");Object.defineProperty(r,"nextTick",{enumerable:!0,get:function(){return c.nextTick}})},{"./contrib/parseuri.js":138,"./socket.js":142,"./transport.js":143,"./transports/index.js":144,"./transports/websocket-constructor.js":146,"./util.js":150}],142:[function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Socket=void 0;const n=e("./transports/index.js"),a=e("./util.js"),s=e("./contrib/parseqs.js"),o=e("./contrib/parseuri.js"),c=i(e("debug")),d=e("@socket.io/component-emitter"),u=e("engine.io-parser"),l=e("./transports/websocket-constructor.js"),h=(0,c.default)("engine.io-client:socket");class f extends d.Emitter{constructor(e,t={}){super(),this.binaryType=l.defaultBinaryType,this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=(0,o.parse)(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=(0,o.parse)(t.host).host),(0,a.installTimerFunctions)(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=(0,s.decode)(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){h('creating transport "%s"',e);const t=Object.assign({},this.opts.query);t.EIO=u.protocol,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return h("options: %j",r),new n.transports[e](r)}open(){let e;if(this.opts.rememberUpgrade&&f.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return h("error while creating transport: %s",e),this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){h("setting transport %s",e.name),this.transport&&(h("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){h('probing transport "%s"',e);let t=this.createTransport(e),r=!1;f.priorWebsocketSuccess=!1;const i=()=>{r||(h('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(i=>{if(!r)if("pong"===i.type&&"probe"===i.data){if(h('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;f.priorWebsocketSuccess="websocket"===t.name,h('pausing current transport "%s"',this.transport.name),this.transport.pause((()=>{r||"closed"!==this.readyState&&(h("changing transport and sending upgrade packet"),d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{h('probe transport "%s" failed',e);const r=new Error("probe error");r.transport=t.name,this.emitReserved("upgradeError",r)}})))};function n(){r||(r=!0,d(),t.close(),t=null)}const a=r=>{const i=new Error("probe error: "+r);i.transport=t.name,n(),h('probe transport "%s" failed because of error: %s',e,r),this.emitReserved("upgradeError",i)};function s(){a("transport closed")}function o(){a("socket closed")}function c(e){t&&e.name!==t.name&&(h('"%s" works - aborting "%s"',e.name,t.name),n())}const d=()=>{t.removeListener("open",i),t.removeListener("error",a),t.removeListener("close",s),this.off("close",o),this.off("upgrading",c)};t.once("open",i),t.once("error",a),t.once("close",s),this.once("close",o),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{r||t.open()}),200):t.open()}onOpen(){if(h("socket open"),this.readyState="open",f.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){h("starting upgrade probes");let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(h('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}else h('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();h("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const r=this.writeBuffer[t].data;if(r&&(e+=(0,a.byteLength)(r)),t>0&&e>this.maxPayload)return h("only send %d out of %d packets",t,this.writeBuffer.length),this.writeBuffer.slice(0,t);e+=2}return h("payload size is %d (max: %d)",e,this.maxPayload),this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,i){if("function"==typeof t&&(i=t,t=void 0),"function"==typeof r&&(i=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const n={type:e,data:t,options:r};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this.onClose("forced close"),h("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?r():e()})):this.upgrading?r():e()),this}onError(e){h("socket error %j",e),f.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(h('socket close with reason: "%s"',e),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let r=0;const i=e.length;for(;r<i;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}}r.Socket=f,f.protocol=u.protocol},{"./contrib/parseqs.js":137,"./contrib/parseuri.js":138,"./transports/index.js":144,"./transports/websocket-constructor.js":146,"./util.js":150,"@socket.io/component-emitter":40,debug:104,"engine.io-parser":155}],143:[function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Transport=r.TransportError=void 0;const n=e("engine.io-parser"),a=e("@socket.io/component-emitter"),s=e("./util.js"),o=i(e("debug")),c=e("./contrib/parseqs.js"),d=(0,o.default)("engine.io-client:transport");class u extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}r.TransportError=u;class l extends a.Emitter{constructor(e){super(),this.writable=!1,(0,s.installTimerFunctions)(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new u(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState?this.write(e):d("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=(0,n.decodePacket)(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=(0,c.encode)(e);return t.length?"?"+t:""}}r.Transport=l},{"./contrib/parseqs.js":137,"./util.js":150,"@socket.io/component-emitter":40,debug:104,"engine.io-parser":155}],144:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.transports=void 0;const i=e("./polling.js"),n=e("./websocket.js"),a=e("./webtransport.js");r.transports={websocket:n.WS,webtransport:a.WT,polling:i.Polling}},{"./polling.js":145,"./websocket.js":147,"./webtransport.js":148}],145:[function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Request=r.Polling=void 0;const n=e("../transport.js"),a=i(e("debug")),s=e("../contrib/yeast.js"),o=e("engine.io-parser"),c=e("./xmlhttprequest.js"),d=e("@socket.io/component-emitter"),u=e("../util.js"),l=e("../globalThis.js"),h=(0,a.default)("engine.io-client:polling");function f(){}const p=null!=new c.XHR({xdomain:!1}).responseType;class m extends n.Transport{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let r=location.port;r||(r=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||r!==e.port}const t=e&&e.forceBase64;this.supportsBinary=p&&!t,this.opts.withCredentials&&(this.cookieJar=(0,c.createCookieJar)())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{h("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(h("we are currently polling - waiting to pause"),e++,this.once("pollComplete",(function(){h("pre-pause polling complete"),--e||t()}))),this.writable||(h("we are currently writing - waiting to pause"),e++,this.once("drain",(function(){h("pre-pause writing complete"),--e||t()})))}else t()}poll(){h("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){h("polling got data %s",e);(0,o.decodePayload)(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState?this.poll():h('ignoring poll - transport state "%s"',this.readyState))}doClose(){const e=()=>{h("writing close packet"),this.write([{type:"close"}])};"open"===this.readyState?(h("transport open - closing"),e()):(h("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,(0,o.encodePayload)(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,s.yeast)()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new b(this.uri(),e)}doWrite(e,t){const r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){h("xhr poll");const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}r.Polling=m;class b extends d.Emitter{constructor(e,t){super(),(0,u.installTimerFunctions)(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=(0,u.pick)(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const r=this.xhr=new c.XHR(t);try{h("xhr open %s: %s",this.method,this.uri),r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{r.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var e;3===r.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(r)),4===r.readyState&&(200===r.status||1223===r.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof r.status?r.status:0)}),0))},h("xhr data %s",this.data),r.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=b.requestsCount++,b.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=f,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete b.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(r.Request=b,b.requestsCount=0,b.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",g);else if("function"==typeof addEventListener){const e="onpagehide"in l.globalThisShim?"pagehide":"unload";addEventListener(e,g,!1)}function g(){for(let e in b.requests)b.requests.hasOwnProperty(e)&&b.requests[e].abort()}},{"../contrib/yeast.js":139,"../globalThis.js":140,"../transport.js":143,"../util.js":150,"./xmlhttprequest.js":149,"@socket.io/component-emitter":40,debug:104,"engine.io-parser":155}],146:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defaultBinaryType=r.usingBrowserWebSocket=r.WebSocket=r.nextTick=void 0;const i=e("../globalThis.js");r.nextTick="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),r.WebSocket=i.globalThisShim.WebSocket||i.globalThisShim.MozWebSocket,r.usingBrowserWebSocket=!0,r.defaultBinaryType="arraybuffer"},{"../globalThis.js":140}],147:[function(e,t,r){(function(t){(function(){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.WS=void 0;const n=e("../transport.js"),a=e("../contrib/yeast.js"),s=e("../util.js"),o=e("./websocket-constructor.js"),c=i(e("debug")),d=e("engine.io-parser"),u=(0,c.default)("engine.io-client:websocket"),l="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class h extends n.Transport{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,r=l?{}:(0,s.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=o.usingBrowserWebSocket&&!l?t?new o.WebSocket(e,t):new o.WebSocket(e):new o.WebSocket(e,t,r)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let r=0;r<e.length;r++){const i=e[r],n=r===e.length-1;(0,d.encodePacket)(i,this.supportsBinary,(e=>{const r={};if(!o.usingBrowserWebSocket&&(i.options&&(r.compress=i.options.compress),this.opts.perMessageDeflate)){("string"==typeof e?t.byteLength(e):e.length)<this.opts.perMessageDeflate.threshold&&(r.compress=!1)}try{o.usingBrowserWebSocket?this.ws.send(e):this.ws.send(e,r)}catch(e){u("websocket closed before onclose event")}n&&(0,o.nextTick)((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,a.yeast)()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!o.WebSocket}}r.WS=h}).call(this)}).call(this,e("buffer").Buffer)},{"../contrib/yeast.js":139,"../transport.js":143,"../util.js":150,"./websocket-constructor.js":146,buffer:94,debug:104,"engine.io-parser":155}],148:[function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.WT=void 0;const n=e("../transport.js"),a=e("./websocket-constructor.js"),s=e("engine.io-parser"),o=(0,i(e("debug")).default)("engine.io-client:webtransport");class c extends n.Transport{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{o("transport closed gracefully"),this.onClose()})).catch((e=>{o("transport closed due to %s",e),this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=(0,s.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),i=(0,s.createPacketEncoderStream)();i.readable.pipeTo(e.writable),this.writer=i.writable.getWriter();const n=()=>{r.read().then((({done:e,value:t})=>{e?o("session is closed"):(o("received chunk: %o",t),this.onPacket(t),n())})).catch((e=>{o("an error occurred while reading: %s",e)}))};n();const a={type:"open"};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this.writer.write(a).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],i=t===e.length-1;this.writer.write(r).then((()=>{i&&(0,a.nextTick)((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}}r.WT=c},{"../transport.js":143,"./websocket-constructor.js":146,debug:104,"engine.io-parser":155}],149:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.createCookieJar=r.XHR=void 0;const i=e("../contrib/has-cors.js"),n=e("../globalThis.js");r.XHR=function(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||i.hasCORS))return new XMLHttpRequest}catch(e){}if(!t)try{return new(n.globalThisShim[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},r.createCookieJar=function(){}},{"../contrib/has-cors.js":136,"../globalThis.js":140}],150:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.byteLength=r.installTimerFunctions=r.pick=void 0;const i=e("./globalThis.js");r.pick=function(e,...t){return t.reduce(((t,r)=>(e.hasOwnProperty(r)&&(t[r]=e[r]),t)),{})};const n=i.globalThisShim.setTimeout,a=i.globalThisShim.clearTimeout;r.installTimerFunctions=function(e,t){t.useNativeTimers?(e.setTimeoutFn=n.bind(i.globalThisShim),e.clearTimeoutFn=a.bind(i.globalThisShim)):(e.setTimeoutFn=i.globalThisShim.setTimeout.bind(i.globalThisShim),e.clearTimeoutFn=i.globalThisShim.clearTimeout.bind(i.globalThisShim))};r.byteLength=function(e){return"string"==typeof e?function(e){let t=0,r=0;for(let i=0,n=e.length;i<n;i++)t=e.charCodeAt(i),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(i++,r+=4);return r}(e):Math.ceil(1.33*(e.byteLength||e.size))}},{"./globalThis.js":140}],151:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ERROR_PACKET=r.PACKET_TYPES_REVERSE=r.PACKET_TYPES=void 0;const i=Object.create(null);r.PACKET_TYPES=i,i.open="0",i.close="1",i.ping="2",i.pong="3",i.message="4",i.upgrade="5",i.noop="6";const n=Object.create(null);r.PACKET_TYPES_REVERSE=n,Object.keys(i).forEach((e=>{n[i[e]]=e}));r.ERROR_PACKET={type:"error",data:"parser error"}},{}],152:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode=r.encode=void 0;const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)n[i.charCodeAt(e)]=e;r.encode=e=>{let t,r=new Uint8Array(e),n=r.length,a="";for(t=0;t<n;t+=3)a+=i[r[t]>>2],a+=i[(3&r[t])<<4|r[t+1]>>4],a+=i[(15&r[t+1])<<2|r[t+2]>>6],a+=i[63&r[t+2]];return n%3==2?a=a.substring(0,a.length-1)+"=":n%3==1&&(a=a.substring(0,a.length-2)+"=="),a};r.decode=e=>{let t,r,i,a,s,o=.75*e.length,c=e.length,d=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);const u=new ArrayBuffer(o),l=new Uint8Array(u);for(t=0;t<c;t+=4)r=n[e.charCodeAt(t)],i=n[e.charCodeAt(t+1)],a=n[e.charCodeAt(t+2)],s=n[e.charCodeAt(t+3)],l[d++]=r<<2|i>>4,l[d++]=(15&i)<<4|a>>2,l[d++]=(3&a)<<6|63&s;return u}},{}],153:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decodePacket=void 0;const i=e("./commons.js"),n=e("./contrib/base64-arraybuffer.js"),a="function"==typeof ArrayBuffer;r.decodePacket=(e,t)=>{if("string"!=typeof e)return{type:"message",data:o(e,t)};const r=e.charAt(0);if("b"===r)return{type:"message",data:s(e.substring(1),t)};return i.PACKET_TYPES_REVERSE[r]?e.length>1?{type:i.PACKET_TYPES_REVERSE[r],data:e.substring(1)}:{type:i.PACKET_TYPES_REVERSE[r]}:i.ERROR_PACKET};const s=(e,t)=>{if(a){const r=(0,n.decode)(e);return o(r,t)}return{base64:!0,data:e}},o=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},{"./commons.js":151,"./contrib/base64-arraybuffer.js":152}],154:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.encodePacket=void 0,r.encodePacketToBinary=function(e,t){if(n&&e.data instanceof Blob)return e.data.arrayBuffer().then(d).then(t);if(a&&(e.data instanceof ArrayBuffer||s(e.data)))return t(d(e.data));o(e,!1,(e=>{u||(u=new TextEncoder),t(u.encode(e))}))};const i=e("./commons.js"),n="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),a="function"==typeof ArrayBuffer,s=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,o=({type:e,data:t},r,o)=>n&&t instanceof Blob?r?o(t):c(t,o):a&&(t instanceof ArrayBuffer||s(t))?r?o(t):c(new Blob([t]),o):o(i.PACKET_TYPES[e]+(t||""));r.encodePacket=o;const c=(e,t)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(",")[1];t("b"+(e||""))},r.readAsDataURL(e)};function d(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let u},{"./commons.js":151}],155:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decodePayload=r.decodePacket=r.encodePayload=r.encodePacket=r.protocol=void 0,r.createPacketEncoderStream=function(){return new TransformStream({transform(e,t){(0,i.encodePacketToBinary)(e,(r=>{const i=r.length;let n;if(i<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,i);else if(i<65536){n=new Uint8Array(3);const e=new DataView(n.buffer);e.setUint8(0,126),e.setUint16(1,i)}else{n=new Uint8Array(9);const e=new DataView(n.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(i))}e.data&&"string"!=typeof e.data&&(n[0]|=128),t.enqueue(n),t.enqueue(r)}))}})},r.createPacketDecoderStream=function(e,t){o||(o=new TextDecoder);const r=[];let i=0,s=-1,u=!1;return new TransformStream({transform(l,h){for(r.push(l);;){if(0===i){if(c(r)<1)break;const e=d(r,1);u=!(128&~e[0]),s=127&e[0],i=s<126?3:126===s?1:2}else if(1===i){if(c(r)<2)break;const e=d(r,2);s=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),i=3}else if(2===i){if(c(r)<8)break;const e=d(r,8),t=new DataView(e.buffer,e.byteOffset,e.length),n=t.getUint32(0);if(n>Math.pow(2,21)-1){h.enqueue(a.ERROR_PACKET);break}s=n*Math.pow(2,32)+t.getUint32(4),i=3}else{if(c(r)<s)break;const e=d(r,s);h.enqueue((0,n.decodePacket)(u?e:o.decode(e),t)),i=0}if(0===s||s>e){h.enqueue(a.ERROR_PACKET);break}}}})};const i=e("./encodePacket.js");Object.defineProperty(r,"encodePacket",{enumerable:!0,get:function(){return i.encodePacket}});const n=e("./decodePacket.js");Object.defineProperty(r,"decodePacket",{enumerable:!0,get:function(){return n.decodePacket}});const a=e("./commons.js"),s=String.fromCharCode(30);r.encodePayload=(e,t)=>{const r=e.length,n=new Array(r);let a=0;e.forEach(((e,o)=>{(0,i.encodePacket)(e,!1,(e=>{n[o]=e,++a===r&&t(n.join(s))}))}))};let o;function c(e){return e.reduce(((e,t)=>e+t.length),0)}function d(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let i=0;for(let n=0;n<t;n++)r[n]=e[0][i++],i===e[0].length&&(e.shift(),i=0);return e.length&&i<e[0].length&&(e[0]=e[0].slice(i)),r}r.decodePayload=(e,t)=>{const r=e.split(s),i=[];for(let e=0;e<r.length;e++){const a=(0,n.decodePacket)(r[e],t);if(i.push(a),"error"===a.type)break}return i},r.protocol=4},{"./commons.js":151,"./decodePacket.js":153,"./encodePacket.js":154}],156:[function(e,t,r){var i=e("safe-buffer").Buffer,n=e("md5.js");t.exports=function(e,t,r,a){if(i.isBuffer(e)||(e=i.from(e,"binary")),t&&(i.isBuffer(t)||(t=i.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var s=r/8,o=i.alloc(s),c=i.alloc(a||0),d=i.alloc(0);s>0||a>0;){var u=new n;u.update(d),u.update(e),t&&u.update(t),d=u.digest();var l=0;if(s>0){var h=o.length-s;l=Math.min(s,d.length),d.copy(o,h,0,l),s-=l}if(l<d.length&&a>0){var f=c.length-a,p=Math.min(a,d.length-l);d.copy(c,f,l,l+p),a-=p}}return d.fill(0),{key:o,iv:c}}},{"md5.js":200,"safe-buffer":284}],157:[function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Logger=void 0;const n=i(e("debug")),a="h264-profile-level-id";r.Logger=class{constructor(e){e?(this._debug=(0,n.default)(`${a}:${e}`),this._warn=(0,n.default)(`${a}:WARN:${e}`),this._error=(0,n.default)(`${a}:ERROR:${e}`)):(this._debug=(0,n.default)(a),this._warn=(0,n.default)(`${a}:WARN`),this._error=(0,n.default)(`${a}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}}},{debug:104}],158:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.generateProfileLevelIdStringForAnswer=r.isSameProfile=r.parseSdpProfileLevelId=r.levelToString=r.profileToString=r.profileLevelIdToString=r.parseProfileLevelId=r.ProfileLevelId=r.Level=r.Profile=void 0;const i=new(e("./Logger").Logger);var n,a;!function(e){e[e.ConstrainedBaseline=1]="ConstrainedBaseline",e[e.Baseline=2]="Baseline",e[e.Main=3]="Main",e[e.ConstrainedHigh=4]="ConstrainedHigh",e[e.High=5]="High",e[e.PredictiveHigh444=6]="PredictiveHigh444"}(n||(r.Profile=n={})),function(e){e[e.L1_b=0]="L1_b",e[e.L1=10]="L1",e[e.L1_1=11]="L1_1",e[e.L1_2=12]="L1_2",e[e.L1_3=13]="L1_3",e[e.L2=20]="L2",e[e.L2_1=21]="L2_1",e[e.L2_2=22]="L2_2",e[e.L3=30]="L3",e[e.L3_1=31]="L3_1",e[e.L3_2=32]="L3_2",e[e.L4=40]="L4",e[e.L4_1=41]="L4_1",e[e.L4_2=42]="L4_2",e[e.L5=50]="L5",e[e.L5_1=51]="L5_1",e[e.L5_2=52]="L5_2"}(a||(r.Level=a={}));class s{constructor(e,t){this.profile=e,this.level=t}}r.ProfileLevelId=s;const o=new s(n.ConstrainedBaseline,a.L3_1);class c{constructor(e){this.mask=~p("x",e),this.masked_value=p("1",e)}isMatch(e){return this.masked_value===(e&this.mask)}}class d{constructor(e,t,r){this.profile_idc=e,this.profile_iop=t,this.profile=r}}const u=[new d(66,new c("x1xx0000"),n.ConstrainedBaseline),new d(77,new c("1xxx0000"),n.ConstrainedBaseline),new d(88,new c("11xx0000"),n.ConstrainedBaseline),new d(66,new c("x0xx0000"),n.Baseline),new d(88,new c("10xx0000"),n.Baseline),new d(77,new c("0x0x0000"),n.Main),new d(100,new c("00000000"),n.High),new d(100,new c("00001100"),n.ConstrainedHigh),new d(244,new c("00000000"),n.PredictiveHigh444)];function l(e){if("string"!=typeof e||6!==e.length)return;const t=parseInt(e,16);if(0===t)return;const r=255&t,n=t>>8&255,o=t>>16&255;let c;switch(r){case a.L1_1:c=16&n?a.L1_b:a.L1_1;break;case a.L1:case a.L1_2:case a.L1_3:case a.L2:case a.L2_1:case a.L2_2:case a.L3:case a.L3_1:case a.L3_2:case a.L4:case a.L4_1:case a.L4_2:case a.L5:case a.L5_1:case a.L5_2:c=r;break;default:return void i.warn(`parseProfileLevelId() | unrecognized level_idc [str:${e}, level_idc:${r}]`)}for(const e of u)if(o===e.profile_idc&&e.profile_iop.isMatch(n))return new s(e.profile,c);i.warn(`parseProfileLevelId() | unrecognized profile_idc/profile_iop combination [str:${e}, profile_idc:${o}, profile_iop:${n}]`)}function h(e){if(e.level==a.L1_b)switch(e.profile){case n.ConstrainedBaseline:return"42f00b";case n.Baseline:return"42100b";case n.Main:return"4d100b";default:return void i.warn(`profileLevelIdToString() | Level 1_b not is allowed for profile ${e.profile}`)}let t;switch(e.profile){case n.ConstrainedBaseline:t="42e0";break;case n.Baseline:t="4200";break;case n.Main:t="4d00";break;case n.ConstrainedHigh:t="640c";break;case n.High:t="6400";break;case n.PredictiveHigh444:t="f400";break;default:return void i.warn(`profileLevelIdToString() | unrecognized profile ${e.profile}`)}let r=e.level.toString(16);return 1===r.length&&(r=`0${r}`),`${t}${r}`}function f(e={}){const t=e["profile-level-id"];return t?l(t):o}function p(e,t){return Number(t[0]===e)<<7|Number(t[1]===e)<<6|Number(t[2]===e)<<5|Number(t[3]===e)<<4|Number(t[4]===e)<<3|Number(t[5]===e)<<2|Number(t[6]===e)<<1|Number(t[7]===e)}function m(e={}){const t=e["level-asymmetry-allowed"];return!0===t||1===t||"1"===t}r.parseProfileLevelId=l,r.profileLevelIdToString=h,r.profileToString=function(e){switch(e){case n.ConstrainedBaseline:return"ConstrainedBaseline";case n.Baseline:return"Baseline";case n.Main:return"Main";case n.ConstrainedHigh:return"ConstrainedHigh";case n.High:return"High";case n.PredictiveHigh444:return"PredictiveHigh444";default:return void i.warn(`profileToString() | unrecognized profile ${e}`)}},r.levelToString=function(e){switch(e){case a.L1_b:return"1b";case a.L1:return"1";case a.L1_1:return"1.1";case a.L1_2:return"1.2";case a.L1_3:return"1.3";case a.L2:return"2";case a.L2_1:return"2.1";case a.L2_2:return"2.2";case a.L3:return"3";case a.L3_1:return"3.1";case a.L3_2:return"3.2";case a.L4:return"4";case a.L4_1:return"4.1";case a.L4_2:return"4.2";case a.L5:return"5";case a.L5_1:return"5.1";case a.L5_2:return"5.2";default:return void i.warn(`levelToString() | unrecognized level ${e}`)}},r.parseSdpProfileLevelId=f,r.isSameProfile=function(e={},t={}){const r=f(e),i=f(t);return Boolean(r&&i&&r.profile===i.profile)},r.generateProfileLevelIdStringForAnswer=function(e={},t={}){if(!e["profile-level-id"]&&!t["profile-level-id"])return void i.warn("generateProfileLevelIdStringForAnswer() | profile-level-id missing in local and remote params");const r=f(e),n=f(t);if(!r)throw new TypeError("invalid local_profile_level_id");if(!n)throw new TypeError("invalid remote_profile_level_id");if(r.profile!==n.profile)throw new TypeError("H264 Profile mismatch");const o=m(e)&&m(t),c=r.level,d=n.level,u=function(e,t){return e===a.L1_b?t!==a.L1&&t!==a.L1_b:t===a.L1_b?e!==a.L1:e<t}(l=c,p=d)?l:p;var l,p;const b=o?c:u;return i.debug(`generateProfileLevelIdStringForAnswer() | result [profile:${r.profile}, level:${b}]`),h(new s(r.profile,b))}},{"./Logger":157}],159:[function(e,t,r){"use strict";var i=e("safe-buffer").Buffer,n=e("stream").Transform;function a(e){n.call(this),this._block=i.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(a,n),a.prototype._transform=function(e,t,r){var i=null;try{this.update(e,t)}catch(e){i=e}r(i)},a.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},a.prototype.update=function(e,t){if(function(e,t){if(!i.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");i.isBuffer(e)||(e=i.from(e,t));for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var a=this._blockOffset;a<this._blockSize;)r[a++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var s=0,o=8*e.length;o>0;++s)this._length[s]+=o,(o=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*o);return this},a.prototype._update=function(){throw new Error("_update is not implemented")},a.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},a.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=a},{inherits:174,"safe-buffer":284,stream:306}],160:[function(e,t,r){var i=r;i.utils=e("./hash/utils"),i.common=e("./hash/common"),i.sha=e("./hash/sha"),i.ripemd=e("./hash/ripemd"),i.hmac=e("./hash/hmac"),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},{"./hash/common":161,"./hash/hmac":162,"./hash/ripemd":163,"./hash/sha":164,"./hash/utils":171}],161:[function(e,t,r){"use strict";var i=e("./utils"),n=e("minimalistic-assert");function a(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=a,a.prototype.update=function(e,t){if(e=i.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=i.join32(e,0,e.length-r,this.endian);for(var n=0;n<e.length;n+=this._delta32)this._update(e,n,n+this._delta32)}return this},a.prototype.digest=function(e){return this.update(this._pad()),n(null===this.pending),this._digest(e)},a.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,r=t-(e+this.padLength)%t,i=new Array(r+this.padLength);i[0]=128;for(var n=1;n<r;n++)i[n]=0;if(e<<=3,"big"===this.endian){for(var a=8;a<this.padLength;a++)i[n++]=0;i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=e>>>24&255,i[n++]=e>>>16&255,i[n++]=e>>>8&255,i[n++]=255&e}else for(i[n++]=255&e,i[n++]=e>>>8&255,i[n++]=e>>>16&255,i[n++]=e>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,a=8;a<this.padLength;a++)i[n++]=0;return i}},{"./utils":171,"minimalistic-assert":239}],162:[function(e,t,r){"use strict";var i=e("./utils"),n=e("minimalistic-assert");function a(e,t,r){if(!(this instanceof a))return new a(e,t,r);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(i.toArray(t,r))}t.exports=a,a.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),n(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=(new this.Hash).update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=(new this.Hash).update(e)},a.prototype.update=function(e,t){return this.inner.update(e,t),this},a.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}},{"./utils":171,"minimalistic-assert":239}],163:[function(e,t,r){"use strict";var i=e("./utils"),n=e("./common"),a=i.rotl32,s=i.sum32,o=i.sum32_3,c=i.sum32_4,d=n.BlockHash;function u(){if(!(this instanceof u))return new u;d.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function l(e,t,r,i){return e<=15?t^r^i:e<=31?t&r|~t&i:e<=47?(t|~r)^i:e<=63?t&i|r&~i:t^(r|~i)}function h(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function f(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}i.inherits(u,d),r.ripemd160=u,u.blockSize=512,u.outSize=160,u.hmacStrength=192,u.padLength=64,u.prototype._update=function(e,t){for(var r=this.h[0],i=this.h[1],n=this.h[2],d=this.h[3],u=this.h[4],v=r,y=i,_=n,w=d,S=u,k=0;k<80;k++){var R=s(a(c(r,l(k,i,n,d),e[p[k]+t],h(k)),b[k]),u);r=u,u=d,d=a(n,10),n=i,i=R,R=s(a(c(v,l(79-k,y,_,w),e[m[k]+t],f(k)),g[k]),S),v=S,S=w,w=a(_,10),_=y,y=R}R=o(this.h[1],n,w),this.h[1]=o(this.h[2],d,S),this.h[2]=o(this.h[3],u,v),this.h[3]=o(this.h[4],r,y),this.h[4]=o(this.h[0],i,_),this.h[0]=R},u.prototype._digest=function(e){return"hex"===e?i.toHex32(this.h,"little"):i.split32(this.h,"little")};var p=[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],m=[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],b=[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],g=[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]},{"./common":161,"./utils":171}],164:[function(e,t,r){"use strict";r.sha1=e("./sha/1"),r.sha224=e("./sha/224"),r.sha256=e("./sha/256"),r.sha384=e("./sha/384"),r.sha512=e("./sha/512")},{"./sha/1":165,"./sha/224":166,"./sha/256":167,"./sha/384":168,"./sha/512":169}],165:[function(e,t,r){"use strict";var i=e("../utils"),n=e("../common"),a=e("./common"),s=i.rotl32,o=i.sum32,c=i.sum32_5,d=a.ft_1,u=n.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}i.inherits(h,u),t.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function(e,t){for(var r=this.W,i=0;i<16;i++)r[i]=e[t+i];for(;i<r.length;i++)r[i]=s(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);var n=this.h[0],a=this.h[1],u=this.h[2],h=this.h[3],f=this.h[4];for(i=0;i<r.length;i++){var p=~~(i/20),m=c(s(n,5),d(p,a,u,h),f,r[i],l[p]);f=h,h=u,u=s(a,30),a=n,n=m}this.h[0]=o(this.h[0],n),this.h[1]=o(this.h[1],a),this.h[2]=o(this.h[2],u),this.h[3]=o(this.h[3],h),this.h[4]=o(this.h[4],f)},h.prototype._digest=function(e){return"hex"===e?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},{"../common":161,"../utils":171,"./common":170}],166:[function(e,t,r){"use strict";var i=e("../utils"),n=e("./256");function a(){if(!(this instanceof a))return new a;n.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}i.inherits(a,n),t.exports=a,a.blockSize=512,a.outSize=224,a.hmacStrength=192,a.padLength=64,a.prototype._digest=function(e){return"hex"===e?i.toHex32(this.h.slice(0,7),"big"):i.split32(this.h.slice(0,7),"big")}},{"../utils":171,"./256":167}],167:[function(e,t,r){"use strict";var i=e("../utils"),n=e("../common"),a=e("./common"),s=e("minimalistic-assert"),o=i.sum32,c=i.sum32_4,d=i.sum32_5,u=a.ch32,l=a.maj32,h=a.s0_256,f=a.s1_256,p=a.g0_256,m=a.g1_256,b=n.BlockHash,g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function v(){if(!(this instanceof v))return new v;b.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}i.inherits(v,b),t.exports=v,v.blockSize=512,v.outSize=256,v.hmacStrength=192,v.padLength=64,v.prototype._update=function(e,t){for(var r=this.W,i=0;i<16;i++)r[i]=e[t+i];for(;i<r.length;i++)r[i]=c(m(r[i-2]),r[i-7],p(r[i-15]),r[i-16]);var n=this.h[0],a=this.h[1],b=this.h[2],g=this.h[3],v=this.h[4],y=this.h[5],_=this.h[6],w=this.h[7];for(s(this.k.length===r.length),i=0;i<r.length;i++){var S=d(w,f(v),u(v,y,_),this.k[i],r[i]),k=o(h(n),l(n,a,b));w=_,_=y,y=v,v=o(g,S),g=b,b=a,a=n,n=o(S,k)}this.h[0]=o(this.h[0],n),this.h[1]=o(this.h[1],a),this.h[2]=o(this.h[2],b),this.h[3]=o(this.h[3],g),this.h[4]=o(this.h[4],v),this.h[5]=o(this.h[5],y),this.h[6]=o(this.h[6],_),this.h[7]=o(this.h[7],w)},v.prototype._digest=function(e){return"hex"===e?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},{"../common":161,"../utils":171,"./common":170,"minimalistic-assert":239}],168:[function(e,t,r){"use strict";var i=e("../utils"),n=e("./512");function a(){if(!(this instanceof a))return new a;n.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}i.inherits(a,n),t.exports=a,a.blockSize=1024,a.outSize=384,a.hmacStrength=192,a.padLength=128,a.prototype._digest=function(e){return"hex"===e?i.toHex32(this.h.slice(0,12),"big"):i.split32(this.h.slice(0,12),"big")}},{"../utils":171,"./512":169}],169:[function(e,t,r){"use strict";var i=e("../utils"),n=e("../common"),a=e("minimalistic-assert"),s=i.rotr64_hi,o=i.rotr64_lo,c=i.shr64_hi,d=i.shr64_lo,u=i.sum64,l=i.sum64_hi,h=i.sum64_lo,f=i.sum64_4_hi,p=i.sum64_4_lo,m=i.sum64_5_hi,b=i.sum64_5_lo,g=n.BlockHash,v=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function y(){if(!(this instanceof y))return new y;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=v,this.W=new Array(160)}function _(e,t,r,i,n){var a=e&r^~e&n;return a<0&&(a+=4294967296),a}function w(e,t,r,i,n,a){var s=t&i^~t&a;return s<0&&(s+=4294967296),s}function S(e,t,r,i,n){var a=e&r^e&n^r&n;return a<0&&(a+=4294967296),a}function k(e,t,r,i,n,a){var s=t&i^t&a^i&a;return s<0&&(s+=4294967296),s}function R(e,t){var r=s(e,t,28)^s(t,e,2)^s(t,e,7);return r<0&&(r+=4294967296),r}function P(e,t){var r=o(e,t,28)^o(t,e,2)^o(t,e,7);return r<0&&(r+=4294967296),r}function M(e,t){var r=s(e,t,14)^s(e,t,18)^s(t,e,9);return r<0&&(r+=4294967296),r}function E(e,t){var r=o(e,t,14)^o(e,t,18)^o(t,e,9);return r<0&&(r+=4294967296),r}function x(e,t){var r=s(e,t,1)^s(e,t,8)^c(e,t,7);return r<0&&(r+=4294967296),r}function T(e,t){var r=o(e,t,1)^o(e,t,8)^d(e,t,7);return r<0&&(r+=4294967296),r}function C(e,t){var r=s(e,t,19)^s(t,e,29)^c(e,t,6);return r<0&&(r+=4294967296),r}function I(e,t){var r=o(e,t,19)^o(t,e,29)^d(e,t,6);return r<0&&(r+=4294967296),r}i.inherits(y,g),t.exports=y,y.blockSize=1024,y.outSize=512,y.hmacStrength=192,y.padLength=128,y.prototype._prepareBlock=function(e,t){for(var r=this.W,i=0;i<32;i++)r[i]=e[t+i];for(;i<r.length;i+=2){var n=C(r[i-4],r[i-3]),a=I(r[i-4],r[i-3]),s=r[i-14],o=r[i-13],c=x(r[i-30],r[i-29]),d=T(r[i-30],r[i-29]),u=r[i-32],l=r[i-31];r[i]=f(n,a,s,o,c,d,u,l),r[i+1]=p(n,a,s,o,c,d,u,l)}},y.prototype._update=function(e,t){this._prepareBlock(e,t);var r=this.W,i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],c=this.h[4],d=this.h[5],f=this.h[6],p=this.h[7],g=this.h[8],v=this.h[9],y=this.h[10],x=this.h[11],T=this.h[12],C=this.h[13],I=this.h[14],D=this.h[15];a(this.k.length===r.length);for(var O=0;O<r.length;O+=2){var A=I,L=D,j=M(g,v),B=E(g,v),N=_(g,v,y,x,T),F=w(g,v,y,x,T,C),U=this.k[O],q=this.k[O+1],z=r[O],V=r[O+1],G=m(A,L,j,B,N,F,U,q,z,V),W=b(A,L,j,B,N,F,U,q,z,V);A=R(i,n),L=P(i,n),j=S(i,n,s,o,c),B=k(i,n,s,o,c,d);var H=l(A,L,j,B),K=h(A,L,j,B);I=T,D=C,T=y,C=x,y=g,x=v,g=l(f,p,G,W),v=h(p,p,G,W),f=c,p=d,c=s,d=o,s=i,o=n,i=l(G,W,H,K),n=h(G,W,H,K)}u(this.h,0,i,n),u(this.h,2,s,o),u(this.h,4,c,d),u(this.h,6,f,p),u(this.h,8,g,v),u(this.h,10,y,x),u(this.h,12,T,C),u(this.h,14,I,D)},y.prototype._digest=function(e){return"hex"===e?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},{"../common":161,"../utils":171,"minimalistic-assert":239}],170:[function(e,t,r){"use strict";var i=e("../utils").rotr32;function n(e,t,r){return e&t^~e&r}function a(e,t,r){return e&t^e&r^t&r}function s(e,t,r){return e^t^r}r.ft_1=function(e,t,r,i){return 0===e?n(t,r,i):1===e||3===e?s(t,r,i):2===e?a(t,r,i):void 0},r.ch32=n,r.maj32=a,r.p32=s,r.s0_256=function(e){return i(e,2)^i(e,13)^i(e,22)},r.s1_256=function(e){return i(e,6)^i(e,11)^i(e,25)},r.g0_256=function(e){return i(e,7)^i(e,18)^e>>>3},r.g1_256=function(e){return i(e,17)^i(e,19)^e>>>10}},{"../utils":171}],171:[function(e,t,r){"use strict";var i=e("minimalistic-assert"),n=e("inherits");function a(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function s(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function o(e){return 1===e.length?"0"+e:e}function c(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=n,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n<e.length;n+=2)r.push(parseInt(e[n]+e[n+1],16))}else for(var i=0,n=0;n<e.length;n++){var s=e.charCodeAt(n);s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=63&s|128):a(e,n)?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++n)),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=63&s|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=63&s|128)}else for(n=0;n<e.length;n++)r[n]=0|e[n];return r},r.toHex=function(e){for(var t="",r=0;r<e.length;r++)t+=o(e[r].toString(16));return t},r.htonl=s,r.toHex32=function(e,t){for(var r="",i=0;i<e.length;i++){var n=e[i];"little"===t&&(n=s(n)),r+=c(n.toString(16))}return r},r.zero2=o,r.zero8=c,r.join32=function(e,t,r,n){var a=r-t;i(a%4==0);for(var s=new Array(a/4),o=0,c=t;o<s.length;o++,c+=4){var d;d="big"===n?e[c]<<24|e[c+1]<<16|e[c+2]<<8|e[c+3]:e[c+3]<<24|e[c+2]<<16|e[c+1]<<8|e[c],s[o]=d>>>0}return s},r.split32=function(e,t){for(var r=new Array(4*e.length),i=0,n=0;i<e.length;i++,n+=4){var a=e[i];"big"===t?(r[n]=a>>>24,r[n+1]=a>>>16&255,r[n+2]=a>>>8&255,r[n+3]=255&a):(r[n+3]=a>>>24,r[n+2]=a>>>16&255,r[n+1]=a>>>8&255,r[n]=255&a)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<<t|e>>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,i){return e+t+r+i>>>0},r.sum32_5=function(e,t,r,i,n){return e+t+r+i+n>>>0},r.sum64=function(e,t,r,i){var n=e[t],a=i+e[t+1]>>>0,s=(a<i?1:0)+r+n;e[t]=s>>>0,e[t+1]=a},r.sum64_hi=function(e,t,r,i){return(t+i>>>0<t?1:0)+e+r>>>0},r.sum64_lo=function(e,t,r,i){return t+i>>>0},r.sum64_4_hi=function(e,t,r,i,n,a,s,o){var c=0,d=t;return c+=(d=d+i>>>0)<t?1:0,c+=(d=d+a>>>0)<a?1:0,e+r+n+s+(c+=(d=d+o>>>0)<o?1:0)>>>0},r.sum64_4_lo=function(e,t,r,i,n,a,s,o){return t+i+a+o>>>0},r.sum64_5_hi=function(e,t,r,i,n,a,s,o,c,d){var u=0,l=t;return u+=(l=l+i>>>0)<t?1:0,u+=(l=l+a>>>0)<a?1:0,u+=(l=l+o>>>0)<o?1:0,e+r+n+s+c+(u+=(l=l+d>>>0)<d?1:0)>>>0},r.sum64_5_lo=function(e,t,r,i,n,a,s,o,c,d){return t+i+a+o+d>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:174,"minimalistic-assert":239}],172:[function(e,t,r){"use strict";var i=e("hash.js"),n=e("minimalistic-crypto-utils"),a=e("minimalistic-assert");function s(e){if(!(this instanceof s))return new s(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=n.toArray(e.entropy,e.entropyEnc||"hex"),r=n.toArray(e.nonce,e.nonceEnc||"hex"),i=n.toArray(e.pers,e.persEnc||"hex");a(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,i)}t.exports=s,s.prototype._init=function(e,t,r){var i=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n<this.V.length;n++)this.K[n]=0,this.V[n]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},s.prototype._hmac=function(){return new i.hmac(this.hash,this.K)},s.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},s.prototype.reseed=function(e,t,r,i){"string"!=typeof t&&(i=r,r=t,t=null),e=n.toArray(e,t),r=n.toArray(r,i),a(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},s.prototype.generate=function(e,t,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(i=r,r=t,t=null),r&&(r=n.toArray(r,i||"hex"),this._update(r));for(var a=[];a.length<e;)this.V=this._hmac().update(this.V).digest(),a=a.concat(this.V);var s=a.slice(0,e);return this._update(r),this._reseed++,n.encode(s,t)}},{"hash.js":160,"minimalistic-assert":239,"minimalistic-crypto-utils":240}],173:[function(e,t,r){
|
|
16
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
17
|
-
r.read=function(e,t,r,i,n){var a,s,o=8*n-i-1,c=(1<<o)-1,d=c>>1,u=-7,l=r?n-1:0,h=r?-1:1,f=e[t+l];for(l+=h,a=f&(1<<-u)-1,f>>=-u,u+=o;u>0;a=256*a+e[t+l],l+=h,u-=8);for(s=a&(1<<-u)-1,a>>=-u,u+=i;u>0;s=256*s+e[t+l],l+=h,u-=8);if(0===a)a=1-d;else{if(a===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,i),a-=d}return(f?-1:1)*s*Math.pow(2,a-i)},r.write=function(e,t,r,i,n,a){var s,o,c,d=8*a-n-1,u=(1<<d)-1,l=u>>1,h=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:a-1,p=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+l>=1?h/c:h*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=u?(o=0,s=u):s+l>=1?(o=(t*c-1)*Math.pow(2,n),s+=l):(o=t*Math.pow(2,l-1)*Math.pow(2,n),s=0));n>=8;e[r+f]=255&o,f+=p,o/=256,n-=8);for(s=s<<n|o,d+=n;d>0;e[r+f]=255&s,f+=p,s/=256,d-=8);e[r+f-p]|=128*m}},{}],174:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},{}],175:[function(e,t,r){function i(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}
|
|
4
|
+
* Bowser - a browser detector
|
|
5
|
+
* https://github.com/lancedikson/bowser
|
|
6
|
+
* MIT License | (c) Dustin Diaz 2012-2015
|
|
7
|
+
* MIT License | (c) Denis Demchenko 2015-2019
|
|
8
|
+
*/class Bt{static getParser(e,t=!1){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new Nt(e,t)}static parse(e){return new Nt(e).getResult()}static get BROWSER_MAP(){return Tt}static get ENGINE_MAP(){return It}static get OS_MAP(){return Et}static get PLATFORMS_MAP(){return Dt}}const Ft=t(p()),$t="VidScale-js";let Ut=class{constructor(e){e?(this._debug=Ft(`${$t}:${e}`),this._info=Ft(`${$t}:INFO:${e}`),this._warn=Ft(`${$t}:WARN:${e}`),this._error=Ft(`${$t}:ERROR:${e}`)):(this._debug=Ft($t),this._info=Ft(`${$t}:INFO`),this._warn=Ft(`${$t}:WARN`),this._error=Ft(`${$t}:ERROR`)),this._debug.log=void 0,this._info.log=void 0,this._warn.log=void 0,this._error.log=void 0}get debug(){return this._debug}get info(){return this._info}get warn(){return this._warn}get error(){return this._error}};var qt,Vt={exports:{}};var Wt=function(){if(qt)return Vt.exports;qt=1;var e,t="object"==typeof Reflect?Reflect:null,r=t&&"function"==typeof t.apply?t.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};e=t&&"function"==typeof t.ownKeys?t.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}Vt.exports=i,Vt.exports.once=function(e,t){return new Promise((function(r,s){function i(r){e.removeListener(t,a),s(r)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}m(e,t,a,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&m(e,"error",t,r)}(e,i,{once:!0})}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function n(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function o(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function c(e,t,r,s){var i,a,c;if(n(r),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),c=a[t]),void 0===c)c=a[t]=r,++e._eventsCount;else if("function"==typeof c?c=a[t]=s?[r,c]:[c,r]:s?c.unshift(r):c.push(r),(i=o(e))>0&&c.length>i&&!c.warned){c.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=c.length,console&&console.warn}return e}function d(){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 p(e,t,r){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=d.bind(s);return i.listener=r,s.wrapFn=i,i}function l(e,t,r){var s=e._events;if(void 0===s)return[];var i=s[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]: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}(i):u(i,i.length)}function h(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 u(e,t){for(var r=new Array(t),s=0;s<t;++s)r[s]=e[s];return r}function m(e,t,r,s){if("function"==typeof e.on)s.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 i(a){s.once&&e.removeEventListener(t,i),r(a)}))}}return Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),i.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},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(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},i.prototype.getMaxListeners=function(){return o(this)},i.prototype.emit=function(e){for(var t=[],s=1;s<arguments.length;s++)t.push(arguments[s]);var i="error"===e,a=this._events;if(void 0!==a)i=i&&void 0===a.error;else if(!i)return!1;if(i){var n;if(t.length>0&&(n=t[0]),n instanceof Error)throw n;var o=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw o.context=n,o}var c=a[e];if(void 0===c)return!1;if("function"==typeof c)r(c,this,t);else{var d=c.length,p=u(c,d);for(s=0;s<d;++s)r(p[s],this,t)}return!0},i.prototype.addListener=function(e,t){return c(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return c(this,e,t,!0)},i.prototype.once=function(e,t){return n(t),this.on(e,p(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return n(t),this.prependListener(e,p(this,e,t)),this},i.prototype.removeListener=function(e,t){var r,s,i,a,o;if(n(t),void 0===(s=this._events))return this;if(void 0===(r=s[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,a=r.length-1;a>=0;a--)if(r[a]===t||r[a].listener===t){o=r[a].listener,i=a;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(s[e]=r[0]),void 0!==s.removeListener&&this.emit("removeListener",e,o||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,r,s;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 i,a=Object.keys(r);for(s=0;s<a.length;++s)"removeListener"!==(i=a[s])&&this.removeAllListeners(i);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(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this},i.prototype.listeners=function(e){return l(this,e,!0)},i.prototype.rawListeners=function(e){return l(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},i.prototype.listenerCount=h,i.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]},Vt.exports}();class Kt extends Wt.EventEmitter{constructor(e){super(),this.setMaxListeners(1/0),this._logger=e||new Ut("EnhancedEventEmitter")}safeEmit(e,...t){try{this.emit(e,...t)}catch(r){this._logger.error("safeEmit() | event listener threw an error [event:%s]:%o",e,r)}}async safeEmitAsPromise(e,...t){return new Promise(((r,s)=>{this.safeEmit(e,...t,r,s)}))}}async function Ht(e){return new Promise((t=>setTimeout((()=>t()),e)))}const Gt=new Ut("Message");class zt{static parse(e){let t;const r={};try{t=JSON.parse(e)}catch(s){return void Gt.error("parse() | invalid JSON: %s",s)}if("object"==typeof t&&!Array.isArray(t)){if(t.request){if(r.request=!0,"string"!=typeof t.method)return void Gt.error("parse() | missing/invalid method field");if("number"!=typeof t.id)return void Gt.error("parse() | missing/invalid id field");r.id=t.id,r.method=t.method,r.data=t.data||{}}else if(t.response){if(r.response=!0,"number"!=typeof t.id)return void Gt.error("parse() | missing/invalid id field");r.id=t.id,t.ok?(r.ok=!0,r.data=t.data||{}):(r.ok=!1,r.errorCode=t.errorCode,r.errorReason=t.errorReason)}else{if(!t.notification)return void Gt.error("parse() | missing request/response field");if(r.notification=!0,"string"!=typeof t.method)return void Gt.error("parse() | missing/invalid method field");r.method=t.method,r.data=t.data||{}}return r}Gt.error("parse() | not an object")}static createRequest(e,t){return{request:!0,id:Math.round(1e7*Math.random()),method:e,data:t||{}}}static createSuccessResponse(e,t){return{response:!0,id:e.id,ok:!0,data:t||{}}}static createErrorResponse(e,t,r){return{response:!0,id:e.id,ok:!1,errorCode:t,errorReason:r}}static createNotification(e,t){return{notification:!0,method:e,data:t||{}}}}const Jt=new Ut("Peer");class Qt extends Kt{constructor(e){super(Jt),Jt.debug("constructor()"),this._closed=!1,this._transport=e,this._connected=!1,this._data={},this._sents=new Map,this._handleTransport()}get closed(){return this._closed}get connected(){return this._connected}get data(){return this._data}set data(e){throw new Error("cannot override data object")}close(){if(!this._closed){Jt.debug("close()"),this._closed=!0,this._connected=!1,this._transport.close();for(const e of this._sents.values())e.close();this.safeEmit("close")}}async request(e,t=void 0){const r=zt.createRequest(e,t);return this._logger.debug("request() [method:%s, id:%s]",e,r.id),await this._transport.send(r),new Promise(((e,t)=>{const s=1500*(15+.1*this._sents.size),i={id:r.id,method:r.method,resolve:t=>{this._sents.delete(r.id)&&(clearTimeout(i.timer),e(t))},reject:e=>{this._sents.delete(r.id)&&(clearTimeout(i.timer),t(e))},timer:setTimeout((()=>{this._sents.delete(r.id)&&t(new Error("request timeout"))}),s),close:()=>{clearTimeout(i.timer),t(new Error("peer closed"))}};this._sents.set(r.id,i)}))}async notify(e,t=void 0){const r=zt.createNotification(e,t);this._logger.debug("notify() [method:%s]",e),await this._transport.send(r)}_handleTransport(){if(this._transport.closed)return this._closed=!0,void setTimeout((()=>{this._closed||(this._connected=!1,this.safeEmit("close"))}));this._transport.on("open",(()=>{this._closed||(Jt.debug('emit "open"'),this._connected=!0,this.safeEmit("open"))})),this._transport.on("disconnected",(()=>{this._closed||(Jt.debug('emit "disconnected"'),this._connected=!1,this.safeEmit("disconnected"))})),this._transport.on("failed",(e=>{this._closed||(Jt.debug('emit "failed" [currentAttempt:%s]',e),this._connected=!1,this.safeEmit("failed",e))})),this._transport.on("close",(()=>{this._closed||(this._closed=!0,Jt.debug('emit "close"'),this._connected=!1,this.safeEmit("close"))})),this._transport.on("message",(e=>{e.request?this._handleRequest(e):e.response?this._handleResponse(e):e.notification&&this._handleNotification(e)}))}_handleRequest(e){try{this.emit("request",e,(t=>{const r=zt.createSuccessResponse(e,t);this._transport.send(r).catch((()=>{}))}),((t,r)=>{t instanceof Error?(r=t.message,t=500):"number"==typeof t&&r instanceof Error&&(r=r.message);const s=zt.createErrorResponse(e,t,r);this._transport.send(s).catch((()=>{}))}))}catch(t){const r=zt.createErrorResponse(e,500,String(t));this._transport.send(r).catch((()=>{}))}}_handleResponse(e){const t=this._sents.get(e.id);if(t)if(e.ok)t.resolve(e.data);else{const r=new Error(e.errorReason);r.code=e.errorCode,t.reject(r)}else Jt.error("received response does not match any sent request [id:%s]",e.id)}_handleNotification(e){this.safeEmit("notification",e)}}const Xt=Object.create(null);Xt.open="0",Xt.close="1",Xt.ping="2",Xt.pong="3",Xt.message="4",Xt.upgrade="5",Xt.noop="6";const Yt=Object.create(null);Object.keys(Xt).forEach((e=>{Yt[Xt[e]]=e}));const Zt={type:"error",data:"parser error"},er="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),tr="function"==typeof ArrayBuffer,rr=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,sr=({type:e,data:t},r,s)=>er&&t instanceof Blob?r?s(t):ir(t,s):tr&&(t instanceof ArrayBuffer||rr(t))?r?s(t):ir(new Blob([t]),s):s(Xt[e]+(t||"")),ir=(e,t)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(",")[1];t("b"+(e||""))},r.readAsDataURL(e)};function ar(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let nr;const or="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",cr="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let Hn=0;Hn<64;Hn++)cr[or.charCodeAt(Hn)]=Hn;const dr="function"==typeof ArrayBuffer,pr=(e,t)=>{if("string"!=typeof e)return{type:"message",data:hr(e,t)};const r=e.charAt(0);if("b"===r)return{type:"message",data:lr(e.substring(1),t)};return Yt[r]?e.length>1?{type:Yt[r],data:e.substring(1)}:{type:Yt[r]}:Zt},lr=(e,t)=>{if(dr){const r=(e=>{let t,r,s,i,a,n=.75*e.length,o=e.length,c=0;"="===e[e.length-1]&&(n--,"="===e[e.length-2]&&n--);const d=new ArrayBuffer(n),p=new Uint8Array(d);for(t=0;t<o;t+=4)r=cr[e.charCodeAt(t)],s=cr[e.charCodeAt(t+1)],i=cr[e.charCodeAt(t+2)],a=cr[e.charCodeAt(t+3)],p[c++]=r<<2|s>>4,p[c++]=(15&s)<<4|i>>2,p[c++]=(3&i)<<6|63&a;return d})(e);return hr(r,t)}return{base64:!0,data:e}},hr=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,ur=String.fromCharCode(30);function mr(){return new TransformStream({transform(e,t){!function(e,t){er&&e.data instanceof Blob?e.data.arrayBuffer().then(ar).then(t):tr&&(e.data instanceof ArrayBuffer||rr(e.data))?t(ar(e.data)):sr(e,!1,(e=>{nr||(nr=new TextEncoder),t(nr.encode(e))}))}(e,(r=>{const s=r.length;let i;if(s<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,s);else if(s<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,s)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(s))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(r)}))}})}let fr;function gr(e){return e.reduce(((e,t)=>e+t.length),0)}function br(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let s=0;for(let i=0;i<t;i++)r[i]=e[0][s++],s===e[0].length&&(e.shift(),s=0);return e.length&&s<e[0].length&&(e[0]=e[0].slice(s)),r}function _r(e){if(e)return function(e){for(var t in _r.prototype)e[t]=_r.prototype[t];return e}(e)}_r.prototype.on=_r.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},_r.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},_r.prototype.off=_r.prototype.removeListener=_r.prototype.removeAllListeners=_r.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,s=this._callbacks["$"+e];if(!s)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<s.length;i++)if((r=s[i])===t||r.fn===t){s.splice(i,1);break}return 0===s.length&&delete this._callbacks["$"+e],this},_r.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],s=1;s<arguments.length;s++)t[s-1]=arguments[s];if(r){s=0;for(var i=(r=r.slice(0)).length;s<i;++s)r[s].apply(this,t)}return this},_r.prototype.emitReserved=_r.prototype.emit,_r.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},_r.prototype.hasListeners=function(e){return!!this.listeners(e).length};const yr="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function wr(e,...t){return t.reduce(((t,r)=>(e.hasOwnProperty(r)&&(t[r]=e[r]),t)),{})}const vr=yr.setTimeout,Sr=yr.clearTimeout;function Rr(e,t){t.useNativeTimers?(e.setTimeoutFn=vr.bind(yr),e.clearTimeoutFn=Sr.bind(yr)):(e.setTimeoutFn=yr.setTimeout.bind(yr),e.clearTimeoutFn=yr.clearTimeout.bind(yr))}class Pr extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class Cr extends _r{constructor(e){super(),this.writable=!1,Rr(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Pr(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=pr(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}(e);return t.length?"?"+t:""}}const kr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Tr=64,Dr={};let Er,Ir=0,xr=0;function Mr(e){let t="";do{t=kr[e%Tr]+t,e=Math.floor(e/Tr)}while(e>0);return t}function Or(){const e=Mr(+new Date);return e!==Er?(Ir=0,Er=e):e+"."+Mr(Ir++)}for(;xr<Tr;xr++)Dr[kr[xr]]=xr;let Lr=!1;try{Lr="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(Kn){}const Ar=Lr;function jr(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||Ar))return new XMLHttpRequest}catch(r){}if(!t)try{return new(yr[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(r){}}function Nr(){}const Br=null!=new jr({xdomain:!1}).responseType;class Fr extends _r{constructor(e,t){super(),Rr(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=wr(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const r=this.xhr=new jr(t);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(s){}if("POST"===this.method)try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(s){}try{r.setRequestHeader("Accept","*/*")}catch(s){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var e;3===r.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(r)),4===r.readyState&&(200===r.status||1223===r.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof r.status?r.status:0)}),0))},r.send(this.data)}catch(s){return void this.setTimeoutFn((()=>{this.onError(s)}),0)}"undefined"!=typeof document&&(this.index=Fr.requestsCount++,Fr.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=Nr,e)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete Fr.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(Fr.requestsCount=0,Fr.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",$r);else if("function"==typeof addEventListener){addEventListener("onpagehide"in yr?"pagehide":"unload",$r,!1)}function $r(){for(let e in Fr.requests)Fr.requests.hasOwnProperty(e)&&Fr.requests[e].abort()}const Ur="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),qr=yr.WebSocket||yr.MozWebSocket,Vr="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const Wr={websocket:class extends Cr{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,r=Vr?{}:wr(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=Vr?new qr(e,t,r):t?new qr(e,t):new qr(e)}catch(Kn){return this.emitReserved("error",Kn)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],s=t===e.length-1;sr(r,this.supportsBinary,(e=>{try{this.ws.send(e)}catch(t){}s&&Ur((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Or()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!qr}},webtransport:class extends Cr{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((e=>{this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=function(e,t){fr||(fr=new TextDecoder);const r=[];let s=0,i=-1,a=!1;return new TransformStream({transform(n,o){for(r.push(n);;){if(0===s){if(gr(r)<1)break;const e=br(r,1);a=!(128&~e[0]),i=127&e[0],s=i<126?3:126===i?1:2}else if(1===s){if(gr(r)<2)break;const e=br(r,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),s=3}else if(2===s){if(gr(r)<8)break;const e=br(r,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>Math.pow(2,21)-1){o.enqueue(Zt);break}i=a*Math.pow(2,32)+t.getUint32(4),s=3}else{if(gr(r)<i)break;const e=br(r,i);o.enqueue(pr(a?e:fr.decode(e),t)),s=0}if(0===i||i>e){o.enqueue(Zt);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),s=mr();s.readable.pipeTo(e.writable),this.writer=s.writable.getWriter();const i=()=>{r.read().then((({done:e,value:t})=>{e||(this.onPacket(t),i())})).catch((e=>{}))};i();const a={type:"open"};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this.writer.write(a).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],s=t===e.length-1;this.writer.write(r).then((()=>{s&&Ur((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends Cr{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let r=location.port;r||(r=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||r!==e.port}const t=e&&e.forceBase64;this.supportsBinary=Br&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const r=e.split(ur),s=[];for(let i=0;i<r.length;i++){const e=pr(r[i],t);if(s.push(e),"error"===e.type)break}return s})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const r=e.length,s=new Array(r);let i=0;e.forEach(((e,a)=>{sr(e,!1,(e=>{s[a]=e,++i===r&&t(s.join(ur))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Or()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Fr(this.uri(),e)}doWrite(e,t){const r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}},Kr=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Hr=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Gr(e){if(e.length>2e3)throw"URI too long";const t=e,r=e.indexOf("["),s=e.indexOf("]");-1!=r&&-1!=s&&(e=e.substring(0,r)+e.substring(r,s).replace(/:/g,";")+e.substring(s,e.length));let i=Kr.exec(e||""),a={},n=14;for(;n--;)a[Hr[n]]=i[n]||"";return-1!=r&&-1!=s&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(e,t){const r=/\/{2,9}/g,s=t.replace(r,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||s.splice(0,1);"/"==t.slice(-1)&&s.splice(s.length-1,1);return s}(0,a.path),a.queryKey=function(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,s){t&&(r[t]=s)})),r}(0,a.query),a}let zr=class e extends _r{constructor(e,t={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=Gr(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=Gr(t.host).host),Rr(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},r=e.split("&");for(let s=0,i=r.length;s<i;s++){let e=r[s].split("=");t[decodeURIComponent(e[0])]=decodeURIComponent(e[1])}return t}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new Wr[e](r)}open(){let t;if(this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(r){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(t){let r=this.createTransport(t),s=!1;e.priorWebsocketSuccess=!1;const i=()=>{s||(r.send([{type:"ping",data:"probe"}]),r.once("packet",(t=>{if(!s)if("pong"===t.type&&"probe"===t.data){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;e.priorWebsocketSuccess="websocket"===r.name,this.transport.pause((()=>{s||"closed"!==this.readyState&&(p(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=r.name,this.emitReserved("upgradeError",e)}})))};function a(){s||(s=!0,p(),r.close(),r=null)}const n=e=>{const t=new Error("probe error: "+e);t.transport=r.name,a(),this.emitReserved("upgradeError",t)};function o(){n("transport closed")}function c(){n("socket closed")}function d(e){r&&e.name!==r.name&&a()}const p=()=>{r.removeListener("open",i),r.removeListener("error",n),r.removeListener("close",o),this.off("close",c),this.off("upgrading",d)};r.once("open",i),r.once("error",n),r.once("close",o),this.once("close",c),this.once("upgrading",d),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn((()=>{s||r.open()}),200):r.open()}onOpen(){if(this.readyState="open",e.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let r=0;r<this.writeBuffer.length;r++){const s=this.writeBuffer[r].data;if(s&&(e+="string"==typeof(t=s)?function(e){let t=0,r=0;for(let s=0,i=e.length;s<i;s++)t=e.charCodeAt(s),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(s++,r+=4);return r}(t):Math.ceil(1.33*(t.byteLength||t.size))),r>0&&e>this.maxPayload)return this.writeBuffer.slice(0,r);e+=2}var t;return this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,s){if("function"==typeof t&&(s=t,t=void 0),"function"==typeof r&&(s=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const i={type:e,data:t,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),s&&this.once("flush",s),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?r():e()})):this.upgrading?r():e()),this}onError(t){e.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let r=0;const s=e.length;for(;r<s;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}};zr.protocol=4;const Jr="function"==typeof ArrayBuffer,Qr=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Xr=Object.prototype.toString,Yr="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Xr.call(Blob),Zr="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Xr.call(File);function es(e){return Jr&&(e instanceof ArrayBuffer||Qr(e))||Yr&&e instanceof Blob||Zr&&e instanceof File}function ts(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(ts(e[t]))return!0;return!1}if(es(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return ts(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&ts(e[r]))return!0;return!1}function rs(e){const t=[],r=e.data,s=e;return s.data=ss(r,t),s.attachments=t.length,{packet:s,buffers:t}}function ss(e,t){if(!e)return e;if(es(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}if(Array.isArray(e)){const r=new Array(e.length);for(let s=0;s<e.length;s++)r[s]=ss(e[s],t);return r}if("object"==typeof e&&!(e instanceof Date)){const r={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=ss(e[s],t));return r}return e}function is(e,t){return e.data=as(e.data,t),delete e.attachments,e}function as(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=as(e[r],t);else if("object"==typeof e)for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=as(e[r],t));return e}const ns=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var os,cs;(cs=os||(os={}))[cs.CONNECT=0]="CONNECT",cs[cs.DISCONNECT=1]="DISCONNECT",cs[cs.EVENT=2]="EVENT",cs[cs.ACK=3]="ACK",cs[cs.CONNECT_ERROR=4]="CONNECT_ERROR",cs[cs.BINARY_EVENT=5]="BINARY_EVENT",cs[cs.BINARY_ACK=6]="BINARY_ACK";function ds(e){return"[object Object]"===Object.prototype.toString.call(e)}class ps extends _r{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const r=t.type===os.BINARY_EVENT;r||t.type===os.BINARY_ACK?(t.type=r?os.EVENT:os.ACK,this.reconstructor=new ls(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!es(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const r={type:Number(e.charAt(0))};if(void 0===os[r.type])throw new Error("unknown packet type "+r.type);if(r.type===os.BINARY_EVENT||r.type===os.BINARY_ACK){const s=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(s,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");r.attachments=Number(i)}if("/"===e.charAt(t+1)){const s=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}r.nsp=e.substring(s,t)}else r.nsp="/";const s=e.charAt(t+1);if(""!==s&&Number(s)==s){const s=t+1;for(;++t;){const r=e.charAt(t);if(null==r||Number(r)!=r){--t;break}if(t===e.length)break}r.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){const s=this.tryParse(e.substr(t));if(!ps.isPayloadValid(r.type,s))throw new Error("invalid payload");r.data=s}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case os.CONNECT:return ds(t);case os.DISCONNECT:return void 0===t;case os.CONNECT_ERROR:return"string"==typeof t||ds(t);case os.EVENT:case os.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===ns.indexOf(t[0]));case os.ACK:case os.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ls{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=is(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const hs=Object.freeze(Object.defineProperty({__proto__:null,Decoder:ps,Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==os.EVENT&&e.type!==os.ACK||!ts(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===os.EVENT?os.BINARY_EVENT:os.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==os.BINARY_EVENT&&e.type!==os.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=rs(e),r=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(r),s}},get PacketType(){return os},protocol:5},Symbol.toStringTag,{value:"Module"}));function us(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const ms=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class fs extends _r{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[us(e,"open",this.onopen.bind(this)),us(e,"packet",this.onpacket.bind(this)),us(e,"error",this.onerror.bind(this)),us(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(ms.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const r={type:os.EVENT,data:t,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,s=t.pop();this._registerAckCallback(e,s),r.id=e}const s=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!s||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,t){var r;const s=null!==(r=this.flags.timeout)&&void 0!==r?r:this._opts.ackTimeout;if(void 0===s)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),s),a=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,e)};a.withError=!0,this.acks[e]=a}emitWithAck(e,...t){return new Promise(((r,s)=>{const i=(e,t)=>e?s(e):r(t);i.withError=!0,t.push(i),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...s)=>{if(r!==this._queue[0])return;return null!==e?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...s)),r.pending=!1,this._drainQueue()})),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:os.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach((e=>{if(!this.sendBuffer.some((t=>String(t.id)===e))){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}}))}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case os.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case os.EVENT:case os.BINARY_EVENT:this.onevent(e);break;case os.ACK:case os.BINARY_ACK:this.onack(e);break;case os.DISCONNECT:this.ondisconnect();break;case os.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let r=!1;return function(...s){r||(r=!0,t.packet({type:os.ACK,id:e,data:s}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:os.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const r of t)r.apply(this,e.data)}}}function gs(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}gs.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+r:e-r}return 0|Math.min(e,this.max)},gs.prototype.reset=function(){this.attempts=0},gs.prototype.setMin=function(e){this.ms=e},gs.prototype.setMax=function(e){this.max=e},gs.prototype.setJitter=function(e){this.jitter=e};class bs extends _r{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,Rr(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(r=t.randomizationFactor)&&void 0!==r?r:.5),this.backoff=new gs({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const s=t.parser||hs;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new zr(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const s=us(t,"open",(function(){r.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},a=us(t,"error",i);if(!1!==this._timeout){const e=this._timeout,r=this.setTimeoutFn((()=>{s(),i(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}return this.subs.push(s),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(us(e,"ping",this.onping.bind(this)),us(e,"data",this.ondata.bind(this)),us(e,"error",this.onerror.bind(this)),us(e,"close",this.onclose.bind(this)),us(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){Ur((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new fs(this,e,t),this.nsps[e]=r),r}_destroy(e){const t=Object.keys(this.nsps);for(const r of t){if(this.nsps[r].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const _s={};function ys(e,t){"object"==typeof e&&(t=e,e=void 0);const r=function(e,t="",r){let s=e;r=r||"undefined"!=typeof location&&location,null==e&&(e=r.protocol+"//"+r.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?r.protocol+e:r.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==r?r.protocol+"//"+e:"https://"+e),s=Gr(e)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const i=-1!==s.host.indexOf(":")?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+i+":"+s.port+t,s.href=s.protocol+"://"+i+(r&&r.port===s.port?"":":"+s.port),s}(e,(t=t||{}).path||"/socket.io"),s=r.source,i=r.id,a=r.path,n=_s[i]&&a in _s[i].nsps;let o;return t.forceNew||t["force new connection"]||!1===t.multiplex||n?o=new bs(s,t):(_s[i]||(_s[i]=new bs(s,t)),o=_s[i]),r.query&&!t.query&&(t.query=r.queryKey),o.socket(r.path,t)}Object.assign(ys,{Manager:bs,Socket:fs,io:ys,connect:ys}),new Ut("WebSocketTransport");const ws=new Ut("WebsocketTransport");class vs extends Kt{constructor(e,t){super(ws),this._closed=!1,this._url=e,this._ws=null,this._socketShouldReconnect=t,this._isConnected=!1,this._lastTimerId=null,this._roomJoined=!1,ws.info("Request received to instantiate websocket transport! with url :%s",e),this.createAndUpdateSocket({connectionType:null})}get connectionStatus(){return this._isConnected}createAndUpdateSocket=async({connectionType:e=null})=>{ws.info("Room close status:%s",this._closed);let t,r=this;if(this._closed)return void ws.info("Websocket already closed!");if(!this._url)return void ws.warn("url not available!");t=null===e?`${this._url}&connectionType=landing`:`${this._url}&connectionType=${e}`,ws.debug("the url is:%s",t),this._ws=new WebSocket(t);let s=0;for(ws.debug("websocketHelper createAndUpdateSocket created a new websocket"),ws.debug("websocketHelper createAndUpdateSocket:%s",this._ws.readyState);1!==this._ws.readyState&&this._socketShouldReconnect;)if(3===this._ws.readyState&&(ws.debug("websocketHelper createAndUpdateSocket"),await Ht(2e3),this._ws=new WebSocket(t),ws.debug("websocketHelper createAndUpdateSocket newly created websocket state:%s",this._ws.readyState)),await Ht(500),s++,s>250){ws.error("No of retries limit to connect with server exhausted!");break}1===this._ws.readyState&&ws.debug(`updated the websocket with ready state -${this._ws.readyState}`),this.safeEmit("connected"),ws.debug(`updating the websocket to redux store with ready state -${this._ws.readyState}`),this._ws.onopen=()=>{this._closed||(ws.debug("Websocket open"),this.safeEmit("open"))},this._isConnected=!0,this._ws.onmessage=e=>{if(this._closed)return;let t=JSON.parse(e.data);switch(t.id){case"ping":{this._lastTimerId&&clearTimeout(this._lastTimerId);let e=this;this._lastTimerId=setTimeout((function(){e._isConnected=!1,this._roomJoined?e.close(4104,"In call connections close as server is unreachable for last 5 seconds!"):e.close(4103,"Landing page socket close by client as server not reachable for a couple of seconds!"),e._socketShouldReconnect&&(e._closed=!1,e.createAndUpdateSocket({connectionType:"inCall"}))}),22e3);const t={id:"pong"};this._ws.send(JSON.stringify(t));break}case"invalidToken":ws.debug("Session token invalid!"),this._socketShouldReconnect=!1,this.safeEmit("invalidToken",t);break;case"alreadyActive":this.safeEmit("alreadyActive",t);break;case"passwordDisabled":this.safeEmit("passwordDisabled",t);break;case"notify":this.safeEmit("notify",t.data);break;case"remotePeerJoin":this.safeEmit("roomStartedP2p",t);break;case"userError":this.safeEmit("userError",t);break;case"validationAlert":this.safeEmit("validationError",t);break;case"joinStatusOnLanding":this.safeEmit("defaultJoinStatus",t);break;default:this.safeEmit("message",t)}},this._ws.onclose=e=>{r._closed||(ws.warn('WebSocket "close" event [wasClean:%s, code:%s, reason:"%s"]',e.wasClean,e.code,e.reason),4503===e.code||4504===e.code?(ws.error("Socket closed with reason",e.reason),r._closed=!0):4500!==e.code&&(ws.debug("trying to reconnect:%s",e.code),r._closed=!1,this._roomJoined?(ws.debug("Trying to join after a network reset while in a meeting"),r.createAndUpdateSocket({connectionType:"inCall"})):(ws.debug("Trying to join after a network reset while on the landing page"),r.createAndUpdateSocket({connectionType:null})),clearTimeout(r._lastTimerId)),this._url=null,ws.info("The websocket closed status is:%s",r._closed),r.safeEmit("close",{code:e.code,reason:e.reason}))}};close(e,t){if(!this._closed){ws.info("close()"),this._closed=!0,this.safeEmit("close",{code:e,reason:t});try{this._ws.onopen=null,this._ws.onclose=null,this._ws.onerror=null,this._ws.onmessage=null,clearTimeout(this._lastTimerId),e&&t?this._ws.close(e,t):this._ws.close()}catch(r){ws.error("close() | error closing the WebSocket: %o",r)}}}async send(e){if(this._closed)ws.error("Transport closed or not yet ready. Try again later!");else try{this._ws.send(JSON.stringify(e))}catch(t){throw ws.warn("send() failed:%o",t),t}}}const Ss=()=>Math.floor(1e10*Math.random()),Rs=()=>"111-111-1111".replace(/[018]/g,(()=>(15&crypto.getRandomValues(new Uint8Array(1))[0]).toString(16)));function Ps(e,t){return function(){return e.apply(t,arguments)}}const{toString:Cs}=Object.prototype,{getPrototypeOf:ks}=Object,Ts=(e=>t=>{const r=Cs.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Ds=e=>(e=e.toLowerCase(),t=>Ts(t)===e),Es=e=>t=>typeof t===e,{isArray:Is}=Array,xs=Es("undefined");const Ms=Ds("ArrayBuffer");const Os=Es("string"),Ls=Es("function"),As=Es("number"),js=e=>null!==e&&"object"==typeof e,Ns=e=>{if("object"!==Ts(e))return!1;const t=ks(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},Bs=Ds("Date"),Fs=Ds("File"),$s=Ds("Blob"),Us=Ds("FileList"),qs=Ds("URLSearchParams");function Vs(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let s,i;if("object"!=typeof e&&(e=[e]),Is(e))for(s=0,i=e.length;s<i;s++)t.call(null,e[s],s,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let n;for(s=0;s<a;s++)n=i[s],t.call(null,e[n],n,e)}}function Ws(e,t){t=t.toLowerCase();const r=Object.keys(e);let s,i=r.length;for(;i-- >0;)if(s=r[i],t===s.toLowerCase())return s;return null}const Ks="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:globalThis,Hs=e=>!xs(e)&&e!==Ks;const Gs=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&ks(Uint8Array)),zs=Ds("HTMLFormElement"),Js=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Qs=Ds("RegExp"),Xs=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),s={};Vs(r,((r,i)=>{let a;!1!==(a=t(r,i,e))&&(s[i]=a||r)})),Object.defineProperties(e,s)},Ys="abcdefghijklmnopqrstuvwxyz",Zs="0123456789",ei={DIGIT:Zs,ALPHA:Ys,ALPHA_DIGIT:Ys+Ys.toUpperCase()+Zs};const ti=Ds("AsyncFunction"),ri={isArray:Is,isArrayBuffer:Ms,isBuffer:function(e){return null!==e&&!xs(e)&&null!==e.constructor&&!xs(e.constructor)&&Ls(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||Ls(e.append)&&("formdata"===(t=Ts(e))||"object"===t&&Ls(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Ms(e.buffer),t},isString:Os,isNumber:As,isBoolean:e=>!0===e||!1===e,isObject:js,isPlainObject:Ns,isUndefined:xs,isDate:Bs,isFile:Fs,isBlob:$s,isRegExp:Qs,isFunction:Ls,isStream:e=>js(e)&&Ls(e.pipe),isURLSearchParams:qs,isTypedArray:Gs,isFileList:Us,forEach:Vs,merge:function e(){const{caseless:t}=Hs(this)&&this||{},r={},s=(s,i)=>{const a=t&&Ws(r,i)||i;Ns(r[a])&&Ns(s)?r[a]=e(r[a],s):Ns(s)?r[a]=e({},s):Is(s)?r[a]=s.slice():r[a]=s};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&Vs(arguments[i],s);return r},extend:(e,t,r,{allOwnKeys:s}={})=>(Vs(t,((t,s)=>{r&&Ls(t)?e[s]=Ps(t,r):e[s]=t}),{allOwnKeys:s}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,s)=>{e.prototype=Object.create(t.prototype,s),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,s)=>{let i,a,n;const o={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)n=i[a],s&&!s(n,e,t)||o[n]||(t[n]=e[n],o[n]=!0);e=!1!==r&&ks(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:Ts,kindOfTest:Ds,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const s=e.indexOf(t,r);return-1!==s&&s===r},toArray:e=>{if(!e)return null;if(Is(e))return e;let t=e.length;if(!As(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const r=s.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const s=[];for(;null!==(r=e.exec(t));)s.push(r);return s},isHTMLForm:zs,hasOwnProperty:Js,hasOwnProp:Js,reduceDescriptors:Xs,freezeMethods:e=>{Xs(e,((t,r)=>{if(Ls(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const s=e[r];Ls(s)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},s=e=>{e.forEach((e=>{r[e]=!0}))};return Is(e)?s(e):s(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:Ws,global:Ks,isContextDefined:Hs,ALPHABET:ei,generateString:(e=16,t=ei.ALPHA_DIGIT)=>{let r="";const{length:s}=t;for(;e--;)r+=t[Math.random()*s|0];return r},isSpecCompliantForm:function(e){return!!(e&&Ls(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),r=(e,s)=>{if(js(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[s]=e;const i=Is(e)?[]:{};return Vs(e,((e,t)=>{const a=r(e,s+1);!xs(a)&&(i[t]=a)})),t[s]=void 0,i}}return e};return r(e,0)},isAsyncFn:ti,isThenable:e=>e&&(js(e)||Ls(e))&&Ls(e.then)&&Ls(e.catch)};function si(e,t,r,s,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),s&&(this.request=s),i&&(this.response=i)}ri.inherits(si,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ri.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const ii=si.prototype,ai={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{ai[e]={value:e}})),Object.defineProperties(si,ai),Object.defineProperty(ii,"isAxiosError",{value:!0}),si.from=(e,t,r,s,i,a)=>{const n=Object.create(ii);return ri.toFlatObject(e,n,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),si.call(n,e.message,t,r,s,i),n.cause=e,n.name=e.name,a&&Object.assign(n,a),n};function ni(e){return ri.isPlainObject(e)||ri.isArray(e)}function oi(e){return ri.endsWith(e,"[]")?e.slice(0,-2):e}function ci(e,t,r){return e?e.concat(t).map((function(e,t){return e=oi(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const di=ri.toFlatObject(ri,{},null,(function(e){return/^is[A-Z]/.test(e)}));function pi(e,t,r){if(!ri.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const s=(r=ri.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!ri.isUndefined(t[e])}))).metaTokens,i=r.visitor||d,a=r.dots,n=r.indexes,o=(r.Blob||"undefined"!=typeof Blob&&Blob)&&ri.isSpecCompliantForm(t);if(!ri.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(ri.isDate(e))return e.toISOString();if(!o&&ri.isBlob(e))throw new si("Blob is not supported. Use a Buffer instead.");return ri.isArrayBuffer(e)||ri.isTypedArray(e)?o&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function d(e,r,i){let o=e;if(e&&!i&&"object"==typeof e)if(ri.endsWith(r,"{}"))r=s?r:r.slice(0,-2),e=JSON.stringify(e);else if(ri.isArray(e)&&function(e){return ri.isArray(e)&&!e.some(ni)}(e)||(ri.isFileList(e)||ri.endsWith(r,"[]"))&&(o=ri.toArray(e)))return r=oi(r),o.forEach((function(e,s){!ri.isUndefined(e)&&null!==e&&t.append(!0===n?ci([r],s,a):null===n?r:r+"[]",c(e))})),!1;return!!ni(e)||(t.append(ci(i,r,a),c(e)),!1)}const p=[],l=Object.assign(di,{defaultVisitor:d,convertValue:c,isVisitable:ni});if(!ri.isObject(e))throw new TypeError("data must be an object");return function e(r,s){if(!ri.isUndefined(r)){if(-1!==p.indexOf(r))throw Error("Circular reference detected in "+s.join("."));p.push(r),ri.forEach(r,(function(r,a){!0===(!(ri.isUndefined(r)||null===r)&&i.call(t,r,ri.isString(a)?a.trim():a,s,l))&&e(r,s?s.concat(a):[a])})),p.pop()}}(e),t}function li(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function hi(e,t){this._pairs=[],e&&pi(e,this,t)}const ui=hi.prototype;function mi(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function fi(e,t,r){if(!t)return e;const s=r&&r.encode||mi,i=r&&r.serialize;let a;if(a=i?i(t,r):ri.isURLSearchParams(t)?t.toString():new hi(t,r).toString(s),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}ui.append=function(e,t){this._pairs.push([e,t])},ui.toString=function(e){const t=e?function(t){return e.call(this,t,li)}:li;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class gi{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ri.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}const bi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},_i={classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:hi,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:(()=>{let e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&("undefined"!=typeof window&&"undefined"!=typeof document)})(),isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]};function yi(e){function t(e,r,s,i){let a=e[i++];const n=Number.isFinite(+a),o=i>=e.length;if(a=!a&&ri.isArray(s)?s.length:a,o)return ri.hasOwnProp(s,a)?s[a]=[s[a],r]:s[a]=r,!n;s[a]&&ri.isObject(s[a])||(s[a]=[]);return t(e,r,s[a],i)&&ri.isArray(s[a])&&(s[a]=function(e){const t={},r=Object.keys(e);let s;const i=r.length;let a;for(s=0;s<i;s++)a=r[s],t[a]=e[a];return t}(s[a])),!n}if(ri.isFormData(e)&&ri.isFunction(e.entries)){const r={};return ri.forEachEntry(e,((e,s)=>{t(function(e){return ri.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),s,r,0)})),r}return null}const wi={transitional:bi,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",s=r.indexOf("application/json")>-1,i=ri.isObject(e);i&&ri.isHTMLForm(e)&&(e=new FormData(e));if(ri.isFormData(e))return s&&s?JSON.stringify(yi(e)):e;if(ri.isArrayBuffer(e)||ri.isBuffer(e)||ri.isStream(e)||ri.isFile(e)||ri.isBlob(e))return e;if(ri.isArrayBufferView(e))return e.buffer;if(ri.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return pi(e,new _i.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,s){return _i.isNode&&ri.isBuffer(e)?(this.append(t,e.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((a=ri.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return pi(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||s?(t.setContentType("application/json",!1),function(e,t,r){if(ri.isString(e))try{return(t||JSON.parse)(e),ri.trim(e)}catch(s){if("SyntaxError"!==s.name)throw s}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||wi.transitional,r=t&&t.forcedJSONParsing,s="json"===this.responseType;if(e&&ri.isString(e)&&(r&&!this.responseType||s)){const r=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e)}catch(i){if(r){if("SyntaxError"===i.name)throw si.from(i,si.ERR_BAD_RESPONSE,this,null,this.response);throw i}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_i.classes.FormData,Blob:_i.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ri.forEach(["delete","get","head","post","put","patch"],(e=>{wi.headers[e]={}}));const vi=ri.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Si=Symbol("internals");function Ri(e){return e&&String(e).trim().toLowerCase()}function Pi(e){return!1===e||null==e?e:ri.isArray(e)?e.map(Pi):String(e)}function Ci(e,t,r,s,i){return ri.isFunction(s)?s.call(this,t,r):(i&&(t=r),ri.isString(t)?ri.isString(s)?-1!==t.indexOf(s):ri.isRegExp(s)?s.test(t):void 0:void 0)}let ki=class{constructor(e){e&&this.set(e)}set(e,t,r){const s=this;function i(e,t,r){const i=Ri(t);if(!i)throw new Error("header name must be a non-empty string");const a=ri.findKey(s,i);(!a||void 0===s[a]||!0===r||void 0===r&&!1!==s[a])&&(s[a||t]=Pi(e))}const a=(e,t)=>ri.forEach(e,((e,r)=>i(e,r,t)));return ri.isPlainObject(e)||e instanceof this.constructor?a(e,t):ri.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?a((e=>{const t={};let r,s,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),s=e.substring(i+1).trim(),!r||t[r]&&vi[r]||("set-cookie"===r?t[r]?t[r].push(s):t[r]=[s]:t[r]=t[r]?t[r]+", "+s:s)})),t})(e),t):null!=e&&i(t,e,r),this}get(e,t){if(e=Ri(e)){const r=ri.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=r.exec(e);)t[s[1]]=s[2];return t}(e);if(ri.isFunction(t))return t.call(this,e,r);if(ri.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Ri(e)){const r=ri.findKey(this,e);return!(!r||void 0===this[r]||t&&!Ci(0,this[r],r,t))}return!1}delete(e,t){const r=this;let s=!1;function i(e){if(e=Ri(e)){const i=ri.findKey(r,e);!i||t&&!Ci(0,r[i],i,t)||(delete r[i],s=!0)}}return ri.isArray(e)?e.forEach(i):i(e),s}clear(e){const t=Object.keys(this);let r=t.length,s=!1;for(;r--;){const i=t[r];e&&!Ci(0,this[i],i,e,!0)||(delete this[i],s=!0)}return s}normalize(e){const t=this,r={};return ri.forEach(this,((s,i)=>{const a=ri.findKey(r,i);if(a)return t[a]=Pi(s),void delete t[i];const n=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(i):String(i).trim();n!==i&&delete t[i],t[n]=Pi(s),r[n]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return ri.forEach(this,((r,s)=>{null!=r&&!1!==r&&(t[s]=e&&ri.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[Si]=this[Si]={accessors:{}}).accessors,r=this.prototype;function s(e){const s=Ri(e);t[s]||(!function(e,t){const r=ri.toCamelCase(" "+t);["get","set","has"].forEach((s=>{Object.defineProperty(e,s+r,{value:function(e,r,i){return this[s].call(this,t,e,r,i)},configurable:!0})}))}(r,e),t[s]=!0)}return ri.isArray(e)?e.forEach(s):s(e),this}};function Ti(e,t){const r=this||wi,s=t||r,i=ki.from(s.headers);let a=s.data;return ri.forEach(e,(function(e){a=e.call(r,a,i.normalize(),t?t.status:void 0)})),i.normalize(),a}function Di(e){return!(!e||!e.__CANCEL__)}function Ei(e,t,r){si.call(this,null==e?"canceled":e,si.ERR_CANCELED,t,r),this.name="CanceledError"}ki.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ri.reduceDescriptors(ki.prototype,(({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}})),ri.freezeMethods(ki),ri.inherits(Ei,si,{__CANCEL__:!0});const Ii=_i.isStandardBrowserEnv?function(){return{write:function(e,t,r,s,i,a){const n=[];n.push(e+"="+encodeURIComponent(t)),ri.isNumber(r)&&n.push("expires="+new Date(r).toGMTString()),ri.isString(s)&&n.push("path="+s),ri.isString(i)&&n.push("domain="+i),!0===a&&n.push("secure"),document.cookie=n.join("; ")},read:function(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function xi(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Mi=_i.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function s(r){let s=r;return e&&(t.setAttribute("href",s),s=t.href),t.setAttribute("href",s),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return r=s(window.location.href),function(e){const t=ri.isString(e)?s(e):e;return t.protocol===r.protocol&&t.host===r.host}}():function(){return function(){return!0}}();function Oi(e,t){let r=0;const s=function(e,t){e=e||10;const r=new Array(e),s=new Array(e);let i,a=0,n=0;return t=void 0!==t?t:1e3,function(o){const c=Date.now(),d=s[n];i||(i=c),r[a]=o,s[a]=c;let p=n,l=0;for(;p!==a;)l+=r[p++],p%=e;if(a=(a+1)%e,a===n&&(n=(n+1)%e),c-i<t)return;const h=d&&c-d;return h?Math.round(1e3*l/h):void 0}}(50,250);return i=>{const a=i.loaded,n=i.lengthComputable?i.total:void 0,o=a-r,c=s(o);r=a;const d={loaded:a,total:n,progress:n?a/n:void 0,bytes:o,rate:c||void 0,estimated:c&&n&&a<=n?(n-a)/c:void 0,event:i};d[t?"download":"upload"]=!0,e(d)}}const Li={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){let s=e.data;const i=ki.from(e.headers).normalize(),a=e.responseType;let n,o;function c(){e.cancelToken&&e.cancelToken.unsubscribe(n),e.signal&&e.signal.removeEventListener("abort",n)}ri.isFormData(s)&&(_i.isStandardBrowserEnv||_i.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.getContentType(/^\s*multipart\/form-data/)?ri.isString(o=i.getContentType())&&i.setContentType(o.replace(/^\s*(multipart\/form-data);+/,"$1")):i.setContentType("multipart/form-data"));let d=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",r=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(t+":"+r))}const p=xi(e.baseURL,e.url);function l(){if(!d)return;const s=ki.from("getAllResponseHeaders"in d&&d.getAllResponseHeaders());!function(e,t,r){const s=r.config.validateStatus;r.status&&s&&!s(r.status)?t(new si("Request failed with status code "+r.status,[si.ERR_BAD_REQUEST,si.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),c()}),(function(e){r(e),c()}),{data:a&&"text"!==a&&"json"!==a?d.response:d.responseText,status:d.status,statusText:d.statusText,headers:s,config:e,request:d}),d=null}if(d.open(e.method.toUpperCase(),fi(p,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,"onloadend"in d?d.onloadend=l:d.onreadystatechange=function(){d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))&&setTimeout(l)},d.onabort=function(){d&&(r(new si("Request aborted",si.ECONNABORTED,e,d)),d=null)},d.onerror=function(){r(new si("Network Error",si.ERR_NETWORK,e,d)),d=null},d.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const s=e.transitional||bi;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new si(t,s.clarifyTimeoutError?si.ETIMEDOUT:si.ECONNABORTED,e,d)),d=null},_i.isStandardBrowserEnv){const t=Mi(p)&&e.xsrfCookieName&&Ii.read(e.xsrfCookieName);t&&i.set(e.xsrfHeaderName,t)}void 0===s&&i.setContentType(null),"setRequestHeader"in d&&ri.forEach(i.toJSON(),(function(e,t){d.setRequestHeader(t,e)})),ri.isUndefined(e.withCredentials)||(d.withCredentials=!!e.withCredentials),a&&"json"!==a&&(d.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&d.addEventListener("progress",Oi(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",Oi(e.onUploadProgress)),(e.cancelToken||e.signal)&&(n=t=>{d&&(r(!t||t.type?new Ei(null,e,d):t),d.abort(),d=null)},e.cancelToken&&e.cancelToken.subscribe(n),e.signal&&(e.signal.aborted?n():e.signal.addEventListener("abort",n)));const h=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(p);h&&-1===_i.protocols.indexOf(h)?r(new si("Unsupported protocol "+h+":",si.ERR_BAD_REQUEST,e)):d.send(s||null)}))}};ri.forEach(Li,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(r){}Object.defineProperty(e,"adapterName",{value:t})}}));const Ai=e=>`- ${e}`,ji=e=>ri.isFunction(e)||null===e||!1===e,Ni=e=>{e=ri.isArray(e)?e:[e];const{length:t}=e;let r,s;const i={};for(let a=0;a<t;a++){let t;if(r=e[a],s=r,!ji(r)&&(s=Li[(t=String(r)).toLowerCase()],void 0===s))throw new si(`Unknown adapter '${t}'`);if(s)break;i[t||"#"+a]=s}if(!s){const e=Object.entries(i).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new si("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Ai).join("\n"):" "+Ai(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return s};function Bi(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ei(null,e)}function Fi(e){Bi(e),e.headers=ki.from(e.headers),e.data=Ti.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Ni(e.adapter||wi.adapter)(e).then((function(t){return Bi(e),t.data=Ti.call(e,e.transformResponse,t),t.headers=ki.from(t.headers),t}),(function(t){return Di(t)||(Bi(e),t&&t.response&&(t.response.data=Ti.call(e,e.transformResponse,t.response),t.response.headers=ki.from(t.response.headers))),Promise.reject(t)}))}const $i=e=>e instanceof ki?e.toJSON():e;function Ui(e,t){t=t||{};const r={};function s(e,t,r){return ri.isPlainObject(e)&&ri.isPlainObject(t)?ri.merge.call({caseless:r},e,t):ri.isPlainObject(t)?ri.merge({},t):ri.isArray(t)?t.slice():t}function i(e,t,r){return ri.isUndefined(t)?ri.isUndefined(e)?void 0:s(void 0,e,r):s(e,t,r)}function a(e,t){if(!ri.isUndefined(t))return s(void 0,t)}function n(e,t){return ri.isUndefined(t)?ri.isUndefined(e)?void 0:s(void 0,e):s(void 0,t)}function o(r,i,a){return a in t?s(r,i):a in e?s(void 0,r):void 0}const c={url:a,method:a,data:a,baseURL:n,transformRequest:n,transformResponse:n,paramsSerializer:n,timeout:n,timeoutMessage:n,withCredentials:n,adapter:n,responseType:n,xsrfCookieName:n,xsrfHeaderName:n,onUploadProgress:n,onDownloadProgress:n,decompress:n,maxContentLength:n,maxBodyLength:n,beforeRedirect:n,transport:n,httpAgent:n,httpsAgent:n,cancelToken:n,socketPath:n,responseEncoding:n,validateStatus:o,headers:(e,t)=>i($i(e),$i(t),!0)};return ri.forEach(Object.keys(Object.assign({},e,t)),(function(s){const a=c[s]||i,n=a(e[s],t[s],s);ri.isUndefined(n)&&a!==o||(r[s]=n)})),r}const qi="1.6.0",Vi={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{Vi[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const Wi={};Vi.transitional=function(e,t,r){return(s,i,a)=>{if(!1===e)throw new si(function(e,t){return"[Axios v1.6.0] Transitional option '"+e+"'"+t+(r?". "+r:"")}(i," has been removed"+(t?" in "+t:"")),si.ERR_DEPRECATED);return t&&!Wi[i]&&(Wi[i]=!0),!e||e(s,i,a)}};const Ki={assertOptions:function(e,t,r){if("object"!=typeof e)throw new si("options must be an object",si.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let i=s.length;for(;i-- >0;){const a=s[i],n=t[a];if(n){const t=e[a],r=void 0===t||n(t,a,e);if(!0!==r)throw new si("option "+a+" must be "+r,si.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new si("Unknown option "+a,si.ERR_BAD_OPTION)}},validators:Vi},Hi=Ki.validators;let Gi=class{constructor(e){this.defaults=e,this.interceptors={request:new gi,response:new gi}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Ui(this.defaults,t);const{transitional:r,paramsSerializer:s,headers:i}=t;void 0!==r&&Ki.assertOptions(r,{silentJSONParsing:Hi.transitional(Hi.boolean),forcedJSONParsing:Hi.transitional(Hi.boolean),clarifyTimeoutError:Hi.transitional(Hi.boolean)},!1),null!=s&&(ri.isFunction(s)?t.paramsSerializer={serialize:s}:Ki.assertOptions(s,{encode:Hi.function,serialize:Hi.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=i&&ri.merge(i.common,i[t.method]);i&&ri.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=ki.concat(a,i);const n=[];let o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));const c=[];let d;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let p,l=0;if(!o){const e=[Fi.bind(this),void 0];for(e.unshift.apply(e,n),e.push.apply(e,c),p=e.length,d=Promise.resolve(t);l<p;)d=d.then(e[l++],e[l++]);return d}p=n.length;let h=t;for(l=0;l<p;){const e=n[l++],t=n[l++];try{h=e(h)}catch(u){t.call(this,u);break}}try{d=Fi.call(this,h)}catch(u){return Promise.reject(u)}for(l=0,p=c.length;l<p;)d=d.then(c[l++],c[l++]);return d}getUri(e){return fi(xi((e=Ui(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}};ri.forEach(["delete","get","head","options"],(function(e){Gi.prototype[e]=function(t,r){return this.request(Ui(r||{},{method:e,url:t,data:(r||{}).data}))}})),ri.forEach(["post","put","patch"],(function(e){function t(t){return function(r,s,i){return this.request(Ui(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}Gi.prototype[e]=t(),Gi.prototype[e+"Form"]=t(!0)}));const zi={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(zi).forEach((([e,t])=>{zi[t]=e}));const Ji=function e(t){const r=new Gi(t),s=Ps(Gi.prototype.request,r);return ri.extend(s,Gi.prototype,r,{allOwnKeys:!0}),ri.extend(s,r,null,{allOwnKeys:!0}),s.create=function(r){return e(Ui(t,r))},s}(wi);Ji.Axios=Gi,Ji.CanceledError=Ei,Ji.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const s=new Promise((e=>{r.subscribe(e),t=e})).then(e);return s.cancel=function(){r.unsubscribe(t)},s},e((function(e,s,i){r.reason||(r.reason=new Ei(e,s,i),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let t;return{token:new e((function(e){t=e})),cancel:t}}},Ji.isCancel=Di,Ji.VERSION=qi,Ji.toFormData=pi,Ji.AxiosError=si,Ji.Cancel=Ji.CanceledError,Ji.all=function(e){return Promise.all(e)},Ji.spread=function(e){return function(t){return e.apply(null,t)}},Ji.isAxiosError=function(e){return ri.isObject(e)&&!0===e.isAxiosError},Ji.mergeConfig=Ui,Ji.AxiosHeaders=ki,Ji.formToJSON=e=>yi(ri.isHTMLForm(e)?new FormData(e):e),Ji.getAdapter=Ni,Ji.HttpStatusCode=zi,Ji.default=Ji;const{Axios:Qi,AxiosError:Xi,CanceledError:Yi,isCancel:Zi,CancelToken:ea,VERSION:ta,all:ra,Cancel:sa,isAxiosError:ia,spread:aa,toFormData:na,AxiosHeaders:oa,HttpStatusCode:ca,formToJSON:da,getAdapter:pa,mergeConfig:la}=Ji,ha={P2P:"p2p",CONFERENCING:"conferencing"},ua="autoscalerv1.videoedge.io/api/vidScale/allocateResources",ma="record",fa="rtmpStreamAndRecord";new Ut("vidscale-url");const ga=async e=>{const{roomId:t,peerId:r,producer:s,consumer:i,sessionToken:a,participantData:n}=e,o=await Ji.post(`${ua}`,{roomId:t,peerId:r,producer:s,consumer:i,sessionToken:a,participantData:n});return new Promise((e=>{try{e(o.data)}catch(t){}}))};var ba,_a,ya,wa,va={};function Sa(){if(wa)return ya;wa=1;const e=_a?ba:(_a=1,ba=(e,t)=>{let r;return function s(){const i=Math.floor(Math.random()*(t-e+1)+e);return r=i===r&&e!==t?s():i,r}});return ya=t=>{const r=e(0,t.length-1);return()=>t[r()]}}const Ra=JSON.parse('["Bulbasaur","Ivysaur","Venusaur","Charmander","Charmeleon","Charizard","Squirtle","Wartortle","Blastoise","Caterpie","Metapod","Butterfree","Weedle","Kakuna","Beedrill","Pidgey","Pidgeotto","Pidgeot","Rattata","Raticate","Spearow","Fearow","Ekans","Arbok","Pikachu","Raichu","Sandshrew","Sandslash","Nidoran♀","Nidorina","Nidoqueen","Nidoran♂","Nidorino","Nidoking","Clefairy","Clefable","Vulpix","Ninetales","Jigglypuff","Wigglytuff","Zubat","Golbat","Oddish","Gloom","Vileplume","Paras","Parasect","Venonat","Venomoth","Diglett","Dugtrio","Meowth","Persian","Psyduck","Golduck","Mankey","Primeape","Growlithe","Arcanine","Poliwag","Poliwhirl","Poliwrath","Abra","Kadabra","Alakazam","Machop","Machoke","Machamp","Bellsprout","Weepinbell","Victreebel","Tentacool","Tentacruel","Geodude","Graveler","Golem","Ponyta","Rapidash","Slowpoke","Slowbro","Magnemite","Magneton","Farfetch\'d","Doduo","Dodrio","Seel","Dewgong","Grimer","Muk","Shellder","Cloyster","Gastly","Haunter","Gengar","Onix","Drowzee","Hypno","Krabby","Kingler","Voltorb","Electrode","Exeggcute","Exeggutor","Cubone","Marowak","Hitmonlee","Hitmonchan","Lickitung","Koffing","Weezing","Rhyhorn","Rhydon","Chansey","Tangela","Kangaskhan","Horsea","Seadra","Goldeen","Seaking","Staryu","Starmie","Mr. Mime","Scyther","Jynx","Electabuzz","Magmar","Pinsir","Tauros","Magikarp","Gyarados","Lapras","Ditto","Eevee","Vaporeon","Jolteon","Flareon","Porygon","Omanyte","Omastar","Kabuto","Kabutops","Aerodactyl","Snorlax","Articuno","Zapdos","Moltres","Dratini","Dragonair","Dragonite","Mewtwo","Mew","Chikorita","Bayleef","Meganium","Cyndaquil","Quilava","Typhlosion","Totodile","Croconaw","Feraligatr","Sentret","Furret","Hoothoot","Noctowl","Ledyba","Ledian","Spinarak","Ariados","Crobat","Chinchou","Lanturn","Pichu","Cleffa","Igglybuff","Togepi","Togetic","Natu","Xatu","Mareep","Flaaffy","Ampharos","Bellossom","Marill","Azumarill","Sudowoodo","Politoed","Hoppip","Skiploom","Jumpluff","Aipom","Sunkern","Sunflora","Yanma","Wooper","Quagsire","Espeon","Umbreon","Murkrow","Slowking","Misdreavus","Unown","Wobbuffet","Girafarig","Pineco","Forretress","Dunsparce","Gligar","Steelix","Snubbull","Granbull","Qwilfish","Scizor","Shuckle","Heracross","Sneasel","Teddiursa","Ursaring","Slugma","Magcargo","Swinub","Piloswine","Corsola","Remoraid","Octillery","Delibird","Mantine","Skarmory","Houndour","Houndoom","Kingdra","Phanpy","Donphan","Porygon2","Stantler","Smeargle","Tyrogue","Hitmontop","Smoochum","Elekid","Magby","Miltank","Blissey","Raikou","Entei","Suicune","Larvitar","Pupitar","Tyranitar","Lugia","Ho-Oh","Celebi","Treecko","Grovyle","Sceptile","Torchic","Combusken","Blaziken","Mudkip","Marshtomp","Swampert","Poochyena","Mightyena","Zigzagoon","Linoone","Wurmple","Silcoon","Beautifly","Cascoon","Dustox","Lotad","Lombre","Ludicolo","Seedot","Nuzleaf","Shiftry","Taillow","Swellow","Wingull","Pelipper","Ralts","Kirlia","Gardevoir","Surskit","Masquerain","Shroomish","Breloom","Slakoth","Vigoroth","Slaking","Nincada","Ninjask","Shedinja","Whismur","Loudred","Exploud","Makuhita","Hariyama","Azurill","Nosepass","Skitty","Delcatty","Sableye","Mawile","Aron","Lairon","Aggron","Meditite","Medicham","Electrike","Manectric","Plusle","Minun","Volbeat","Illumise","Roselia","Gulpin","Swalot","Carvanha","Sharpedo","Wailmer","Wailord","Numel","Camerupt","Torkoal","Spoink","Grumpig","Spinda","Trapinch","Vibrava","Flygon","Cacnea","Cacturne","Swablu","Altaria","Zangoose","Seviper","Lunatone","Solrock","Barboach","Whiscash","Corphish","Crawdaunt","Baltoy","Claydol","Lileep","Cradily","Anorith","Armaldo","Feebas","Milotic","Castform","Kecleon","Shuppet","Banette","Duskull","Dusclops","Tropius","Chimecho","Absol","Wynaut","Snorunt","Glalie","Spheal","Sealeo","Walrein","Clamperl","Huntail","Gorebyss","Relicanth","Luvdisc","Bagon","Shelgon","Salamence","Beldum","Metang","Metagross","Regirock","Regice","Registeel","Latias","Latios","Kyogre","Groudon","Rayquaza","Jirachi","Deoxys","Turtwig","Grotle","Torterra","Chimchar","Monferno","Infernape","Piplup","Prinplup","Empoleon","Starly","Staravia","Staraptor","Bidoof","Bibarel","Kricketot","Kricketune","Shinx","Luxio","Luxray","Budew","Roserade","Cranidos","Rampardos","Shieldon","Bastiodon","Burmy","Wormadam","Mothim","Combee","Vespiquen","Pachirisu","Buizel","Floatzel","Cherubi","Cherrim","Shellos","Gastrodon","Ambipom","Drifloon","Drifblim","Buneary","Lopunny","Mismagius","Honchkrow","Glameow","Purugly","Chingling","Stunky","Skuntank","Bronzor","Bronzong","Bonsly","Mime Jr.","Happiny","Chatot","Spiritomb","Gible","Gabite","Garchomp","Munchlax","Riolu","Lucario","Hippopotas","Hippowdon","Skorupi","Drapion","Croagunk","Toxicroak","Carnivine","Finneon","Lumineon","Mantyke","Snover","Abomasnow","Weavile","Magnezone","Lickilicky","Rhyperior","Tangrowth","Electivire","Magmortar","Togekiss","Yanmega","Leafeon","Glaceon","Gliscor","Mamoswine","Porygon-Z","Gallade","Probopass","Dusknoir","Froslass","Rotom","Uxie","Mesprit","Azelf","Dialga","Palkia","Heatran","Regigigas","Giratina","Cresselia","Phione","Manaphy","Darkrai","Shaymin","Arceus","Victini","Snivy","Servine","Serperior","Tepig","Pignite","Emboar","Oshawott","Dewott","Samurott","Patrat","Watchog","Lillipup","Herdier","Stoutland","Purrloin","Liepard","Pansage","Simisage","Pansear","Simisear","Panpour","Simipour","Munna","Musharna","Pidove","Tranquill","Unfezant","Blitzle","Zebstrika","Roggenrola","Boldore","Gigalith","Woobat","Swoobat","Drilbur","Excadrill","Audino","Timburr","Gurdurr","Conkeldurr","Tympole","Palpitoad","Seismitoad","Throh","Sawk","Sewaddle","Swadloon","Leavanny","Venipede","Whirlipede","Scolipede","Cottonee","Whimsicott","Petilil","Lilligant","Basculin","Sandile","Krokorok","Krookodile","Darumaka","Darmanitan","Maractus","Dwebble","Crustle","Scraggy","Scrafty","Sigilyph","Yamask","Cofagrigus","Tirtouga","Carracosta","Archen","Archeops","Trubbish","Garbodor","Zorua","Zoroark","Minccino","Cinccino","Gothita","Gothorita","Gothitelle","Solosis","Duosion","Reuniclus","Ducklett","Swanna","Vanillite","Vanillish","Vanilluxe","Deerling","Sawsbuck","Emolga","Karrablast","Escavalier","Foongus","Amoonguss","Frillish","Jellicent","Alomomola","Joltik","Galvantula","Ferroseed","Ferrothorn","Klink","Klang","Klinklang","Tynamo","Eelektrik","Eelektross","Elgyem","Beheeyem","Litwick","Lampent","Chandelure","Axew","Fraxure","Haxorus","Cubchoo","Beartic","Cryogonal","Shelmet","Accelgor","Stunfisk","Mienfoo","Mienshao","Druddigon","Golett","Golurk","Pawniard","Bisharp","Bouffalant","Rufflet","Braviary","Vullaby","Mandibuzz","Heatmor","Durant","Deino","Zweilous","Hydreigon","Larvesta","Volcarona","Cobalion","Terrakion","Virizion","Tornadus","Thundurus","Reshiram","Zekrom","Landorus","Kyurem","Keldeo","Meloetta","Genesect","Chespin","Quilladin","Chesnaught","Fennekin","Braixen","Delphox","Froakie","Frogadier","Greninja","Bunnelby","Diggersby","Fletchling","Fletchinder","Talonflame","Scatterbug","Spewpa","Vivillon","Litleo","Pyroar","Flabébé","Floette","Florges","Skiddo","Gogoat","Pancham","Pangoro","Furfrou","Espurr","Meowstic","Honedge","Doublade","Aegislash","Spritzee","Aromatisse","Swirlix","Slurpuff","Inkay","Malamar","Binacle","Barbaracle","Skrelp","Dragalge","Clauncher","Clawitzer","Helioptile","Heliolisk","Tyrunt","Tyrantrum","Amaura","Aurorus","Sylveon","Hawlucha","Dedenne","Carbink","Goomy","Sliggoo","Goodra","Klefki","Phantump","Trevenant","Pumpkaboo","Gourgeist","Bergmite","Avalugg","Noibat","Noivern","Xerneas","Yveltal","Zygarde","Diancie","Hoopa","Volcanion","Rowlet","Dartrix","Decidueye","Litten","Torracat","Incineroar","Popplio","Brionne","Primarina","Pikipek","Trumbeak","Toucannon","Yungoos","Gumshoos","Grubbin","Charjabug","Vikavolt","Crabrawler","Crabominable","Oricorio","Cutiefly","Ribombee","Rockruff","Lycanroc","Wishiwashi","Mareanie","Toxapex","Mudbray","Mudsdale","Dewpider","Araquanid","Fomantis","Lurantis","Morelull","Shiinotic","Salandit","Salazzle","Stufful","Bewear","Bounsweet","Steenee","Tsareena","Comfey","Oranguru","Passimian","Wimpod","Golisopod","Sandygast","Palossand","Pyukumuku","Type: Null","Silvally","Minior","Komala","Turtonator","Togedemaru","Mimikyu","Bruxish","Drampa","Dhelmise","Jangmo-o","Hakamo-o","Kommo-o","Tapu Koko","Tapu Lele","Tapu Bulu","Tapu Fini","Cosmog","Cosmoem","Solgaleo","Lunala","Nihilego","Buzzwole","Pheromosa","Xurkitree","Celesteela","Kartana","Guzzlord","Necrozma","Magearna","Marshadow","Poipole","Naganadel","Stakataka","Blacephalon","Zeraora","Meltan","Melmetal","Grookey","Thwackey","Rillaboom","Scorbunny","Raboot","Cinderace","Sobble","Drizzile","Inteleon","Skwovet","Greedent","Rookidee","Corvisquire","Corviknight","Blipbug","Dottler","Orbeetle","Nickit","Thievul","Gossifleur","Eldegoss","Wooloo","Dubwool","Chewtle","Drednaw","Yamper","Boltund","Rolycoly","Carkol","Coalossal","Applin","Flapple","Appletun","Silicobra","Sandaconda","Cramorant","Arrokuda","Barraskewda","Toxel","Toxtricity","Sizzlipede","Centiskorch","Clobbopus","Grapploct","Sinistea","Polteageist","Hatenna","Hattrem","Hatterene","Impidimp","Morgrem","Grimmsnarl","Obstagoon","Perrserker","Cursola","Sirfetch\'d","Mr. Rime","Runerigus","Milcery","Alcremie","Falinks","Pincurchin","Snom","Frosmoth","Stonjourner","Eiscue","Indeedee","Morpeko","Cufant","Copperajah","Dracozolt","Arctozolt","Dracovish","Arctovish","Duraludon","Dreepy","Drakloak","Dragapult","Zacian","Zamazenta","Eternatus","Kubfu","Urshifu","Zarude","Regieleki","Regidrago","Glastrier","Spectrier","Calyrex","Wyrdeer","Kleavor","Ursaluna","Basculegion","Sneasler","Overqwil","Enamorus","Sprigatito","Floragato","Meowscarada","Fuecoco","Crocalor","Skeledirge","Quaxly","Quaxwell","Quaquaval","Lechonk","Oinkologne","Tarountula","Spidops","Nymble","Lokix","Pawmi","Pawmo","Pawmot","Tandemaus","Maushold","Fidough","Dachsbun","Smoliv","Dolliv","Arboliva","Squawkabilly","Nacli","Naclstack","Garganacl","Charcadet","Armarouge","Ceruledge","Tadbulb","Bellibolt","Wattrel","Kilowattrel","Maschiff","Mabosstiff","Shroodle","Grafaiai","Bramblin","Brambleghast","Toedscool","Toedscruel","Klawf","Capsakid","Scovillain","Rellor","Rabsca","Flittle","Espathra","Tinkatink","Tinkatuff","Tinkaton","Wiglett","Wugtrio","Bombirdier","Finizen","Palafin","Varoom","Revavroom","Cyclizar","Orthworm","Glimmet","Glimmora","Greavard","Houndstone","Flamigo","Cetoddle","Cetitan","Veluza","Dondozo","Tatsugiri","Annihilape","Clodsire","Farigiraf","Dudunsparce","Kingambit","Great Tusk","Scream Tail","Brute Bonnet","Flutter Mane","Slither Wing","Sandy Shocks","Iron Treads","Iron Bundle","Iron Hands","Iron Jugulis","Iron Moth","Iron Thorns","Frigibax","Arctibax","Baxcalibur","Gimmighoul","Gholdengo","Wo-Chien","Chien-Pao","Ting-Lu","Chi-Yu","Roaring Moon","Iron Valiant","Koraidon","Miraidon","Walking Wake","Iron Leaves","Dipplin","Poltchageist","Sinistcha","Okidogi","Mankidori","Fezandipiti","Ogerpon","Archaludon","Hydrapple","Gouging Fire","Raging Bolt","Iron Boulder","Iron Crown","Terapagos","Pecharunt"]');var Pa;function Ca(){if(Pa)return va;Pa=1;const e=Sa(),t=Ra,r="https://github.com/sindresorhus/pokemon",s=`Please report to ${r}/issues if we missed something.`,i=new Set(["de","en","fr","es","ja","ko","ru","th","zh-Hans","zh-Hant"]),a=new Map;function n(e="en"){if("en"===e)return t;if(!i.has(e))throw new Error(`Localized list for language code '${e}' does not exist. Pull request welcome: ${r}`);return function(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}(`./data/${e.toLowerCase()}.json`)}return va.all=n,va.random=(t="en")=>{if(a.has(t))return a.get(t)();const r=n(t),s=e(r);return a.set(t,s),s()},va.getName=(e,t="en")=>{const r=n(t)[e-1];if(!r)throw new Error(`Pokémon with ID '${e}' does not exist. ${s}`);return r},va.getId=(e,t="en")=>{const r=n(t).indexOf(e);if(-1===r)throw new Error(`Pokémon with name '${e}' does not exist for language code '${t}'. ${s}`);return r+1},va.languages=i,va}var ka=Ca();function Ta(){return ka.random("en")}new Ut("device-manager");const Da=async()=>{let e=[],t=[],r=[];return new Promise(((s,i)=>{navigator.mediaDevices.enumerateDevices().then((function(i){i.forEach(((s,i)=>{if("audioinput"===s.kind){let e=s.label||`Mic ${Number(i)+1}`;t.push({label:e,deviceId:s.deviceId})}if("videoinput"===s.kind){let t=s.label||`Camera ${Number(i)+1}`;e.push({label:t,deviceId:s.deviceId})}if("audiooutput"===s.kind){let e=s.label||`Speaker ${Number(i)+1}`;r.push({label:e,deviceId:s.deviceId})}})),s({audioDevices:t,audioDevicesOutput:r,videoDevices:e})}))}))},Ea=async()=>{let e={videoDevices:[],audioDevices:[],audioOutputDevices:[]};const t=await(async()=>{let e=[];return navigator.mediaDevices.enumerateDevices().then((function(t){let r=void 0!==t.find((e=>"videoinput"===e.kind));return new Promise(((t,s)=>{navigator.mediaDevices.getUserMedia({video:r}).then((r=>{navigator.mediaDevices.enumerateDevices().then((function(s){s.forEach((function(t,r){if("videoinput"===t.kind){let s=t.label||`Camera ${Number(r)+1}`;e.push({label:s,deviceId:t.deviceId})}})),r.getTracks().forEach((e=>{e.stop()})),t({videoDevices:e})}))})).catch((function(e){t({error:e.name,reason:e.message})}))}))})).catch((function(e){}))})();let r=null;if(t.error){switch(t.error){case"TypeError":break;case"AbortError":r=`${t.error} : ${t.reason}!! Your Camera is currently being used !! If you wish to join the room with video, please close the other tab / browser wherever it is being used and refresh this page!!`;break;case"NotAllowedError":r=`${t.error} : ${t.reason}!! You have denied the access to your Camera!! If you wish to join the room with video, please allow the camera access by clicking on the camera icon in the address bar Or by going to " chrome://settings/content#media-stream-mic " link in your chrome.`;break;case"NotFoundError":r=`${t.error} : ${t.reason}!! No Camera could be found!! If you have a camera or microphone in your computer but it is not able to detect them, please refresh your browser again or restart the browser after closing all the opened tabs.`;break;case"NotReadableError":r=`${t.error} : ${t.reason}!! If you have a camera in your computer but it is not able to detect it as it may have been used by some other browser / tab, please refresh your browser again after closing the tab using the camera or restart the browser after closing all the opened tabs.`}return{success:!1,reason:{code:"EDV01",type:"DeviceError",text:r}}}t.videoDevices&&t.videoDevices.length>0&&(e.videoDevices=t.videoDevices);const s=await(async()=>{let e=[];return navigator.mediaDevices.enumerateDevices().then((function(t){let r=void 0!==t.find((e=>"audioinput"===e.kind));return new Promise(((t,s)=>{navigator.mediaDevices.getUserMedia({audio:r}).then((r=>{navigator.mediaDevices.enumerateDevices().then((function(s){s.forEach((function(t,r){if("audioinput"===t.kind){let s=t.label||`Mic ${Number(r)+1}`;e.push({label:s,deviceId:t.deviceId})}})),r.getTracks().forEach((e=>{e.stop()})),t({audioDevices:e})}))})).catch((function(e){t({error:e.name,reason:e.message})}))}))})).catch((function(e){}))})();let i=null;if(s.error){switch(s.error){case"NotAllowedError":i=`${s.error} : ${s.reason}!! You have denied the access to your Mic!! If you wish to join the room with video, please allow the camera access by clicking on the camera icon in the address bar Or by going to " chrome://settings/content#media-stream-mic " link in your chrome.`;break;case"NotFoundError":i=`${s.error} : ${s.reason}!! No Microphone could be found!! If you have a camera or microphone in your computer but it is not able to detect them, please refresh your browser again or restart the browser after closing all the opened tabs.`;break;case"NotReadableError":i=`${s.error} : ${s.reason}!! A hardware error occured at the OS OR browser Or Webpage level. If you have a microphone in your computer but it is not able to detect them, please refresh your browser again or restart the browser after closing all the opened tabs.`}return{success:!1,reason:{code:"EDA01",type:"DeviceError",text:i}}}s.audioDevices&&s.audioDevices.length>0&&(e.audioDevices=s.audioDevices);const a=await(async()=>{let e=[];return navigator.mediaDevices.enumerateDevices().then((function(t){let r=void 0!==t.find((e=>"audiooutput"===e.kind));return new Promise(((t,s)=>{navigator.mediaDevices.getUserMedia({audio:r}).then((r=>{navigator.mediaDevices.enumerateDevices().then((function(s){s.forEach((function(t,r){if("audiooutput"===t.kind){let s=t.label||`Speaker ${Number(r)+1}`;e.push({label:s,deviceId:t.deviceId})}})),r.getTracks().forEach((e=>{e.stop()})),t({audioDevicesOutput:e})}))})).catch((function(e){t({error:e.name,reason:e.message})}))}))})).catch((function(e){}))})();return a.error?{success:!1,reason:{code:"EDAO01",type:"DeviceError",text:"Some error occured while accessing your speaker. Please try again again after some time."}}:(a.audioDevicesOutput&&a.audioDevicesOutput.length>0&&(e.audioOutputDevices=a.audioDevicesOutput),{success:!0,deviceList:e})},Ia=new Ut("Room"),xa={small:{width:{ideal:160},height:{ideal:120}},qvga:{width:{ideal:320},height:{ideal:240}},vga:{width:{ideal:640},height:{ideal:480}},hd:{width:{ideal:1280},height:{ideal:720}}},Ma={optional:[{googDscp:!0}]};let Oa;class La extends Wt.EventEmitter{static async listDevices(){if(Oa)return Ia.info("Device list already exists:%O",Oa),{success:!0,deviceList:Oa};const e=await Ea();return e.success?(Oa=e.deviceList,{success:!0,deviceList:e.deviceList}):{success:!1,reason:e.reason}}static async joinRoom({sessionToken:e,roomId:t,peerId:r,peerName:s,produce:i=!0,produceAudio:a=!0,produceVideo:n=!0,consume:o=!0,videoResolution:c="hd",forceVp8:d=!1,forceVp9:p=!1,forceH264:l=!1,h264Profile:h="high",forcePCMU:u=!1,forcePCMA:m=!1,forceFPS:f=25,enableWebcamLayers:g=!0,numSimulcastStreams:b=3,autoGainControl:_=!0,echoCancellation:y=!0,noiseSuppression:w=!0,sampleRate:v=44e3,channelCount:S=1,videoBitRates:R=[700,250,75],share:P=!1,shareAudio:C=!1,enableSharingLayers:k=!0,shareBitRates:T=[2500,1250,500],audioDeviceId:D=null,videoDeviceId:E=null}={}){if(!e)throw new Error("Session token is required to join the room.");["hd","vga","qvga"].includes(c)||(Ia.warn("Invalid video resolution value. setting it to default value of 'hd' "),c="hd"),"boolean"!=typeof i&&(Ia.warn("Produe should either be true or false"),i=Boolean(i)),"boolean"!=typeof a&&(Ia.warn("ProduceAudio should either be true or false"),a=Boolean(a)),"boolean"!=typeof n&&(Ia.warn("ProduceVideo should either be true or false"),n=Boolean(n)),"boolean"!=typeof o&&(Ia.warn("Consume should either be true or false"),o=Boolean(o)),"boolean"!=typeof d&&(Ia.warn("forceVp8 should either be true or false"),d=Boolean(d)),"boolean"!=typeof p&&(Ia.warn("forceVp9 should either be true or false"),p=Boolean(p)),"boolean"!=typeof l&&(Ia.warn("forceH264 should either be true or false"),l=Boolean(l)),["high","low"].includes(h.toLowerCase())||(Ia.warn("h264Profile should either be 'high' or 'low'"),h="high"),(!Number.isInteger(f)||Number.isInteger(f)&&(f>65||f<5))&&(Ia.warn("forceFPS should be a number between 5 to 65, default value is 25 fps."),f=25),"boolean"!=typeof g&&(Ia.warn("enableWebcamLayers should either be true or false"),g=Boolean(g)),(!Number.isInteger(b)||Number.isInteger(b)&&(b>3||b<1))&&(Ia.warn("numSimulcastStreams should be a number between 1 to 3, default value is 3."),b=3),Array.isArray(R)&&R.length>=1&&R.length<=3&&R.every((e=>Number.isInteger(e)&&e>=75&&e<=800))?Ia.debug("videoBitRates values are correct"):(Ia.warn("videobitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[75,250,75]'"),R=[75,75,75]),"boolean"!=typeof u&&(Ia.warn("forcePCMU should either be true or false"),u=Boolean(u)),"boolean"!=typeof m&&(Ia.warn("forcePCMA should either be true or false"),m=Boolean(m)),"boolean"!=typeof _&&(Ia.warn("autoGainControl should either be true or false"),_=Boolean(_)),"boolean"!=typeof y&&(Ia.warn("echoCancellation should either be true or false"),y=Boolean(y)),"boolean"!=typeof w&&(Ia.warn("noiseSuppression should either be true or false"),w=Boolean(w)),(!Number.isInteger(v)||Number.isInteger(v)&&(v>64e3||v<8e3))&&(Ia.warn("sampleRate should be a number between 8000 to 64000, default value is 44000 Khz."),v=44e3),(!Number.isInteger(S)||Number.isInteger(S)&&(S>2||S<1))&&(Ia.warn("sampleRate should be a number between 1 to 2, default value is 1, which is a mono audio."),S=1),"boolean"!=typeof P&&(Ia.warn("share should either be true or false"),P=Boolean(P)),"boolean"!=typeof C&&(Ia.warn("shareAudio should either be true or false"),C=Boolean(C)),"boolean"!=typeof k&&(Ia.warn("enableSharingLayers should either be true or false"),k=Boolean(k)),Array.isArray(T)&&T.length>=1&&T.length<=3&&T.every((e=>Number.isInteger(e)&&e>=500&&e<=2500))?Ia.debug("shareBitRates values are correct"):(Ia.warn("sharebitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[2500,1250,500]'"),T=[2500,1250,500]);try{Ia.info("session token:%s",e),r||(r=Rs()),t||(t=Ss()),s||(s=Ta());const I=Bt.parse(window.navigator.userAgent),x=I.browser.name,M=I.browser.version,O={name:r,participantType:"moderator",browserName:x,browserVersion:M,os:I.os.name};Ia.info("browser details are:%O",I);const L={sessionToken:e,roomId:t,peerId:r,consumerReplicas:0,producer:i,consumer:o,participantData:O};let A={};Ia.debug("Received input parameters are:%O",L);const j=await async function({sessionToken:e,roomId:t,peerId:r,consumerReplicas:s,producer:i=!0,consumer:a=!0,participantData:n}){const o=await ga({sessionToken:e,roomId:t,peerId:r,producer:i,consumer:a,participantData:n});return o.success?{success:!0,wsUrl:`wss://${o.data.url}/?roomId=${t}&peerId=${r}&consumerReplicas=${s}`,roomUrl:`https://${o.data.url}`,core:o.data.core}:{success:!1,errorText:o.data.reason,errorCode:o.data.code}}(L);return j.success&&j.wsUrl&&j.core?(A.url=j.wsUrl,A.core=j.core,Ia.debug("VidScale url is:",A.url),new La({peerId:r,roomId:t,peerName:s,produce:i,produceAudio:a,produceVideo:n,consume:o,videoResolution:c,forceVp8:d,forceVp9:p,forceH264:l,h264Profile:h,forceFPS:f,forcePCMU:u,forcePCMA:m,enableWebcamLayers:g,numSimulcastStreams:b,autoGainControl:_,echoCancellation:y,noiseSuppression:w,sampleRate:v,channelCount:S,videoBitRates:R,share:P,shareAudio:C,enableSharingLayers:k,shareBitRates:T,outputData:A,audioDeviceId:D,videoDeviceId:E})):(Ia.warn("Vidscale returned success as false. with error:%O",j),j)}catch(I){throw Ia.error("Failed to join room:",I.message),I}}constructor({peerId:e,roomId:t,peerName:r,produce:s,produceAudio:i,produceVideo:a,consume:n,videoResolution:o,forceVp8:c,forceVp9:d,forceH264:p,h264Profile:l,forceFPS:h,forcePCMU:u,forcePCMA:m,enableWebcamLayers:f,numSimulcastStreams:g,autoGainControl:b,echoCancellation:_,noiseSuppression:y,sampleRate:w,channelCount:v,videoBitRates:S,share:R,shareAudio:P,enableSharingLayers:C,shareBitRates:k,outputData:T,audioDeviceId:D,videoDeviceId:E}){super(),this._closed=!1,this._roomStatus="initialised",this._cignal=null,this._sendTransport=null,this._recvTransport=null,this._device=new Ct.Device,this._webCamProducer=null,this._micProducer=null,this._shareProducer=null,this._shareAudioProducer=null,this._producers=new Map,this._consumers=new Map,this._peers=new Map,this._data={...T},this._micStream=null,this._webCamStream=null,this._webcam={device:null,resolution:o},this._mic={device:null},this._deviceList=Oa||null,this._externalVideo=null,this._externalVideoStream=null,this._forceVP8=Boolean(c),this._forceH264=Boolean(p),this._forceVP9=Boolean(d),this._enableWebcamLayers=Boolean(f),this._numSimulcastStreams=g,this._enableSharingLayers=Boolean(C),this._client=Bt.parse(window.navigator.userAgent),this._cignalConnected=!1,this._reconnectionInitiated=!1,this._restartIceInProgressSendTransport=!1,this._restartIceInProgressRecvTransport=!1,this._activeSpeaker=null,this.init({roomId:t,peerId:e,peerName:r,produce:s,produceAudio:i,produceVideo:a,consume:n,videoResolution:o,forceVp8:c,forceVp9:d,forceH264:p,h264Profile:l,forceFPS:h,forcePCMU:u,forcePCMA:m,enableWebcamLayers:f,numSimulcastStreams:g,autoGainControl:b,echoCancellation:_,noiseSuppression:y,sampleRate:w,channelCount:v,videoBitRates:S,share:R,shareAudio:P,enableSharingLayers:C,shareBitRates:k,audioDeviceId:D,videoDeviceId:E})}get closed(){return this._closed}get data(){return this._data}set data(e){throw new Error("Setting the whole data object is not possible!")}get peers(){return this._peers}set peers(e){throw new Error("Setting the whole peers object is not possible!")}get transports(){return{produce:this._sendTransport,consume:this._recvTransport}}set transports(e){throw new Error("Setting of transport is not possible!")}get videoStream(){return this._webCamStream}get audioStream(){return this._micStream}get clientAgent(){return this._client}get activeParameters(){return this._data.inputParams}get deviceList(){return this._deviceList?this._deviceList:{videoDevices:[],audioDevices:[],audioOutputDevices:[]}}set deviceList(e){throw new Error("Setting of deviceList is not possible!")}get currentlyActiveSpeaker(){return this._activeSpeaker}set currentlyActiveSpeaker(e){throw new Error("Setting of currentActivespeaker is not possible!")}async init(e){Ia.debug("init() | The input parameters are:%O",e),this.data.inputParams=e;const t=Ct.detectDevice();Ia.debug("The device is:%O",t),await this.listDevicesInternal(),await this.join()}close(){this._closed||(this._closed=!0,Ia.debug("close()"),this._cignal.close(),this._sendTransport&&this._sendTransport.close(),this._recvTransport&&this._recvTransport.close(),this._roomStatus="closed")}async leaveRoom(){Ia.debug("Leave room is called!!"),"connected"===this._roomStatus?(await this._cignal.notify("leaveRoom",{}),this._sendTransport&&(this._sendTransport.close(),this._sendTransport=null),this._recvTransport&&(this._recvTransport.close(),this._recvTransport=null),this._webCamStream&&this._webCamStream.getVideoTracks().forEach((e=>{e.stop(),Ia.debug("Video Track stopped")})),this._micStream&&this._micStream.getAudioTracks().forEach((e=>{e.stop(),Ia.debug("Mic Track stopped")})),this._roomStatus="closed",this._cignal.close()):Ia.error("The room state is:%s",this._roomStatus)}async closeRoom(){await this._cignal.notify("closeRoom",{}),this.leaveRoom()}async listDevicesInternal(){if(navigator.mediaDevices.ondevicechange=async e=>{let t=await Da();Ia.info("Media devices changed!:%O",t),t.audioDevices&&t.audioDevices.length>0&&(this._deviceList.audioDevices=t.audioDevices),t.videoDevices&&t.videoDevices.length>0&&(this._deviceList.videoDevices=t.videoDevices),t.audioDevices&&t.audioDevices.length>0&&(this._deviceList.audioOutputDevices=t.audioDevicesOutput),Oa=this._deviceList,this.emit("deviceListUpdated")},!this._deviceList){const e=await Ea();if(e.success)return this._deviceList=e.deviceList,void(Oa=this._deviceList)}}async join(){const e=new vs(this.data.url,{retries:10,factor:2,minTimeout:1e3,maxTimeout:8e3});this._cignal=new Qt(e),this._cignal.on("open",(async()=>{this._cignalConnected=!0,this._sendTransport||this._recvTransport?(!this._sendTransport||"failed"!==this._sendTransport.connectionState&&"disconnected"!==this._sendTransport.connectionState?Ia.debug("Nothing to in case of socket reconnection with send transport status:%s",this._sendTransport?.connectionState):(Ia.debug("Ws reconnected after network outage. Need to do ICE restarts for send transport."),this.restartIceSendTransport()),!this._recvTransport||"failed"!==this._recvTransport.connectionState&&"disconnected"!==this._recvTransport.connectionState?Ia.debug("Nothing to in case of socket reconnection with recv transport status:%s",this._recvTransport?.connectionState):(Ia.debug("Ws reconnected after network outage. Need to do ICE restarts for recv transport."),this.restartIceRecvTransport())):(Ia.debug("Ws connected for first time. Need to go with the regular flow."),await this._joinRoom())})),this._cignal.on("failed",(()=>{})),this._cignal.on("disconnected",(()=>{Ia.debug("ws disconnected!"),this._cignalConnected=!1})),this._cignal.on("close",(()=>{this._closed||this._reconnectionInitiated||this.close()})),this._cignal.on("request",(async(e,t,r)=>{switch(Ia.debug('cignal "request" event [method:%s, data:%o]',e.method,e.data),this._cignalConnected=!0,e.method){case"newConsumer":{if(!this.data.inputParams.consume){r(403,"I do not want to consume");break}const{peerId:i,producerId:a,id:n,kind:o,rtpParameters:c,type:d,appData:p,producerPaused:l}=e.data;try{const e=await this._recvTransport.consume({id:n,producerId:a,kind:o,rtpParameters:c,streamId:`${i}-${p.share?"share":"mic-webcam"}`,appData:{...p,peerId:i}});this._consumers.set(e.id,e),e.on("transportclose",(()=>{this._consumers.delete(e.id)}));const{spatialLayers:r,temporalLayers:s}=Ct.parseScalabilityMode(e.rtpParameters.encodings[0].scalabilityMode),h=this._peers.get(i);Ia.debug(`Consumer created for peerId ${i} for kind ${e.kind}`);let u={...h,[p.share?`ss${e.kind}`:e.kind]:{consumerId:e.id,type:d,locallyPaused:!1,remotelyPaused:l,rtpParameters:e.rtpParameters,spatialLayers:r,temporalLayers:s,preferredSpatialLayer:r-1,preferredTemporalLayer:s-1,priority:1,codec:e.rtpParameters.codecs[0].mimeType.split("/")[1],track:e.track,share:p.share}};this._peers.set(i,u),t(),Ia.debug("Going to emit mic start / videostart"),"audio"===e.kind?p.share?this.emit("ssAudioStart",{peerId:i,audioTrack:e.track,type:"remote"}):this.emit("micStart",{peerId:i,audioTrack:e.track,type:"remote"}):"video"===e.kind&&(p.share?this.emit("ssVideoStart",{peerId:i,videoTrack:e.track,type:"remote"}):this.emit("videoStart",{peerId:i,videoTrack:e.track,type:"remote"}))}catch(s){throw Ia.error('"newConsumer" request failed:%o',s),s}break}}})),this._cignal.on("notification",(e=>{switch("activeSpeaker"!==e.method&&Ia.debug('proto "notification" event [method:%s, data:%o]',e.method,e.data),this._cignalConnected=!0,e.method){case"producerScore":{const{producerId:t,score:r}=e.data;break}case"newPeer":{const t=e.data;this._peers.set(t.id,{...t,consumers:[]}),this.emit("newPeer",{peerId:t.id,peerName:t.displayName,type:"remote"});break}case"peerClosed":{const{peerId:t}=e.data;this._peers.delete(t),this.emit("peerLeft",{peerId:t});break}case"roomClosed":Ia.debug("Room closed. No need to reconnect socket"),this.close();break;case"consumerClosed":{const{consumerId:t}=e.data,r=this._consumers.get(t);if(Ia.debug("Consumer closed for consumerId:%s, type:%s",t,r?.kind),!r)break;const{peerId:s,share:i}=r.appData;let a=i?`ss${r.kind}`:r.kind;r.close(),this._consumers.delete(t);let n=this._peers.get(s);Ia.debug("Peer data before deletion:%O",n),n[a]&&n[a].consumerId===t&&delete n[a],Ia.debug("Peer data after deletion:%O",n),this._peers.set(s,n),"audio"===a?(Ia.debug("Going to emit micEnd, consumer closed for audio"),i?this.emit("ssAudioStop",{peerId:s,track:null,type:"remote"}):this.emit("micEnd",{peerId:s,track:null,type:"remote"})):"video"===a&&(Ia.debug("Going to emit videoEnd, consumer closed for video"),i?this.emit("ssVideoStop",{peerId:s,track:null,type:"remote"}):this.emit("videoEnd",{peerId:s,track:null,type:"remote"}));break}case"consumerPaused":{const{consumerId:t}=e.data,r=this._consumers.get(t);if(!r)break;r.pause();break}case"consumerResumed":{const{consumerId:t}=e.data,r=this._consumers.get(t);if(!r)break;r.resume();break}case"consumerLayersChanged":{const{consumerId:t,spatialLayer:r,temporalLayer:s}=e.data;if(!this._consumers.get(t))break;break}case"consumerScore":{const{consumerId:t,score:r}=e.data;break}case"activeSpeaker":{const{peerId:t,volume:r}=e.data;this._activeSpeaker=e.data,this.emit("activeSpeaker",{peerId:t,volume:r});break}case"peerMuted":{const{peerId:t}=e.data;this.emit("peerMuted",{peerId:t,type:"remote"});break}case"peerUnMuted":{const{peerId:t}=e.data;this.emit("peerUnMuted",{peerId:t,type:"remote"});break}default:Ia.error('unknown protoo notification.method "%s"',e.method)}}))}async restartIceSendTransport(){if(Ia.debug("restartIce SendTransport()"),this._restartIceInProgressSendTransport)Ia.warn("Restart ice already in progress for send transport! wait 4 completion b4 next request!");else{try{if(this._sendTransport&&("failed"===this._sendTransport.connectionState||"disconnected"===this._sendTransport.connectionState)){this._restartIceInProgressSendTransport=!0,Ia.debug("Restarting ICE for send transport");const e=await this._cignal.request("restartIce",{transportId:this._sendTransport.id,peerId:this._peerId});await this._sendTransport.restartIce({iceParameters:e}),this._restartIceInProgressSendTransport=!1}}catch(e){Ia.error("restartIce SendTransport() | failed:%o",e)}this._reconnectionInitiated=!1}}async restartIceRecvTransport(){if(Ia.debug("restartIce RecvTransport()"),this._restartIceInProgressRecvTransport)Ia.warn("Restart ice already in progress for recv transport! wait 4 completion b4 next request!");else{try{if(this._recvTransport&&("failed"===this._recvTransport.connectionState||"disconnected"===this._recvTransport.connectionState)){this._restartIceInProgressRecvTransport=!0,Ia.debug("Restarting ICE for recv transport");const e=await this._cignal.request("restartIce",{transportId:this._recvTransport.id,peerId:this._peerId});await this._recvTransport.restartIce({iceParameters:e}),this._restartIceInProgressRecvTransport=!1}}catch(e){Ia.error("restartIce RecvTransport() | failed:%o",e)}this._reconnectionInitiated=!1}}async _joinRoom(){Ia.debug("_joinRoom()");try{const e=await this._cignal.request("getRouterRtpCapabilities",{coreNumber:this.data.core});if(Ia.debug("Router rtp capabilities created:%O",e),Ia.debug("Input params are:",this.data.inputParams),await this._device.load({routerRtpCapabilities:e}),this.data.inputParams.produce){Ia.debug("Going to create webrtctransport send");const e=await this._cignal.request("createWebRtcTransport",{forceTcp:this._forceTcp||!1,producing:!0,consuming:!1,sctpCapabilities:this._useDataChannel?this._device.sctpCapabilities:void 0}),{id:t,iceParameters:r,iceCandidates:s,dtlsParameters:i,sctpParameters:a}=e;Ia.debug("Transport info is:%O",e),this._sendTransport=this._device.createSendTransport({id:t,iceParameters:r,iceCandidates:s,dtlsParameters:{...i,role:"auto"},sctpParameters:a,iceServers:[],proprietaryConstraints:Ma,additionalSettings:{encodedInsertableStreams:this._e2eKey&&e2e.isSupported()}}),this._sendTransport.on("connect",(({iceParameters:e,dtlsParameters:t},r,s)=>{this._cignal.request("connectWebRtcTransport",{transportId:this._sendTransport.id,iceParameters:e,dtlsParameters:t}).then(r).catch(s)})),this._sendTransport.on("produce",(async({kind:e,rtpParameters:t,appData:r},s,i)=>{try{const{id:i}=await this._cignal.request("produce",{transportId:this._sendTransport.id,kind:e,rtpParameters:t,appData:r});s({id:i})}catch(a){i(a)}}))}if(this.data.inputParams.consume){Ia.debug("Going to create webrtctransport recv");const e=await this._cignal.request("createWebRtcTransport",{forceTcp:this._forceTcp,producing:!1,consuming:!0,sctpCapabilities:this._useDataChannel?this._device.sctpCapabilities:void 0}),{id:t,iceParameters:r,iceCandidates:s,dtlsParameters:i,sctpParameters:a}=e;Ia.debug("Transport info is:%O",e),this._recvTransport=this._device.createRecvTransport({id:t,iceParameters:r,iceCandidates:s,dtlsParameters:{...i,role:"auto"},sctpParameters:a,iceServers:[],additionalSettings:{encodedInsertableStreams:this._e2eKey&&e2e.isSupported()}}),this._recvTransport.on("connect",(({iceParameters:e,dtlsParameters:t},r,s)=>{this._cignal.request("connectWebRtcTransport",{transportId:this._recvTransport.id,iceParameters:e,dtlsParameters:t}).then(r).catch(s)}))}const{peers:t}=await this._cignal.request("join",{displayName:this.data.inputParams.peerName,device:this._device,rtpCapabilities:this.data.inputParams.consume?this._device.rtpCapabilities:void 0,sctpCapabilities:this._useDataChannel&&this.data.inputParams.consume?this._device.sctpCapabilities:void 0});this.emit("newPeer",{peerId:this.data.inputParams.peerId,peerName:this.data.inputParams.peerName,type:"local"}),this._roomStatus="connected",Ia.debug("All availablepeers in this room are::%O",t);for(const r of t)this._peers.set(r.id,{...r,consumers:[]}),Ia.debug("new peer is:%O",r),this.emit("newPeer",{peerId:r.id,peerName:r.displayName,type:"remote"});this.data.inputParams.produce&&(this.data.inputParams.produceAudio?this.enableMic({deviceId:this.data.inputParams.audioDeviceId?this.data.inputParams.audioDeviceId:null}):Ia.debug("No need to produce audio!"),(this._device.canProduce("video")||this._externalVideo)&&(this.data.inputParams.produceVideo?this.enableCam({deviceId:this.data.inputParams.videoDeviceId?this.data.inputParams.videoDeviceId:null}):Ia.debug("No need to produce video!"),this.data.inputParams.share&&this.enableShare({shareAudio:this.data.inputParams.shareAudio,enableSharingLayers:this._enableSharingLayers,shareBitRates:this.data.inputParams.shareBitRates})),this._sendTransport.on("connectionstatechange",(e=>{"connected"===e&&Ia.debug("Send transport now connected!")})))}catch(e){Ia.error("_joinRoom() failed:%o",e),this.emit("error",{code:"EJR001",text:"Join room request failed!"}),this.close()}}async enableMic({deviceId:e=null,autoGainControl:t,noiseSuppression:r,echoCancellation:s,channelCount:i,sampleRate:a,forcePCMU:n,forcePCMA:o}={}){if(Ia.debug("enableMic()"),!this.data.inputParams.produce)return Ia.debug("Produce status is set to false!"),{success:!1,error:!0,code:"REID007",text:"Error while trying to start Mic/Audio. Produce flag need to set to true while joining room in order to enable Mic/Audio."};if("connected"!==this._roomStatus)return Ia.debug("Room status is not connected yet!"),{success:!1,error:!0,code:"REID008",text:`Error while trying to start Mic/Audio as room not in connected status. Current room status:!${this._roomStatus}`,possibleReasons:"Did you forget to call joinRoom before enabling Mic? OR if you have already initiated the joinRoom process, then Mic will be enabled automatically once room join process completes."};if(this._micProducer)return Ia.debug("Mic is already active!"),{success:!1,warning:!0,code:"RWID002",text:"Error while trying to start Mic/Audio. Mic/Audio is already active!"};if(!this._device.canProduce("audio"))return Ia.error("enableMic() | cannot produce audio"),{success:!1,error:!0,code:"REID009",text:"Error while trying to start Mic/Audio. Mic/Audio couldnot be activated due to limitations on this device. If you think this device has a functional Mic and the problem persists even after multiple retries, please contact technical support with the error code."};let c,d;n&&"boolean"==typeof n&&(this.data.inputParams.forcePCMU=n),o&&"boolean"==typeof o&&(this.data.inputParams.forcePCMA=o),t&&"boolean"==typeof t&&(this.data.inputParams.autoGainControl=t),s&&"boolean"==typeof s&&(this.data.inputParams.echoCancellation=s),r&&"boolean"==typeof r&&(this.data.inputParams.noiseSuppression=r),a&&Number.isInteger(a)&&a<64e3&&a>8e3&&(this.data.inputParams.sampleRate=a),i&&Number.isInteger(i)&&i>0&&i<3&&(this.data.inputParams.channelCount=i);try{if(this._externalVideo)this._micStream=await this._getExternalVideoStream(),c=this._micStream.getAudioTracks()[0].clone();else{if(e?(d=this._deviceList.audioDevices.find((t=>t.deviceId===e)),d||(Ia.warn("Selected audio input deviceId:%s not found",e),d=this._deviceList.audioDevices[0])):d=this._deviceList.audioDevices[0],this._mic.device=d,!d)return Ia.error("No mic device found! Can't start audio!"),{success:!1,reason:"No mic available for starting audio!"};e&&this.data.inputParams.audioDeviceId!==e&&(this.data.inputParams.audioDeviceId=e),Ia.debug("enableMic() | calling getUserMedia()");try{this._micStream=await navigator.mediaDevices.getUserMedia({audio:{deviceId:{ideal:d.deviceId},echoCancellation:this.data.inputParams.echoCancellation,noiseSuppression:this.data.inputParams.noiseSuppression,autoGainControl:this.data.inputParams.autoGainControl,sampleRate:this.data.inputParams.sampleRate,channelCount:this.data.inputParams.channelCount}}),c=this._micStream.getAudioTracks()[0]}catch(Kn){throw new Error("Error while acquiring mic. Possible issue with audio constraint values",Kn)}}this._micProducer=await this._sendTransport.produce({track:c,codecOptions:this.data.inputParams.forcePCMU||this.data.inputParams.forcePCMA?void 0:{opusStereo:!1,opusDtx:!0,opusFec:!0,opusNack:!0},codec:this.data.inputParams.forcePCMU?this._device.rtpCapabilities.codecs.find((e=>"audio/pcmu"===e.mimeType.toLowerCase())):this.data.inputParams.forcePCMA?this._device.rtpCapabilities.codecs.find((e=>"audio/pcma"===e.mimeType.toLowerCase())):void 0}),this._producers.set("audio",{id:this._micProducer.id,paused:this._micProducer.paused,track:this._micProducer.track,rtpParameters:this._micProducer.rtpParameters,codec:this._micProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("micStart",{peerId:this.data.inputParams.peerId,audioTrack:this._micProducer.track,type:"local"}),this._micProducer.on("transportclose",(()=>{this._micProducer=null})),this._micProducer.on("trackended",(()=>{this.disableMic().catch((()=>{}))}))}catch(p){Ia.error("enableMic() | failed:%o",p),this.emit("error",{code:"EID002",text:"Error enabling microphone!"}),c&&c.stop()}}async disableMic(){if(Ia.debug("disableMic()"),this._micStream&&this._micStream.getAudioTracks().forEach((e=>e.stop())),this._micProducer){this._micProducer.close(),this._producers.delete("audio");try{await this._cignal.request("closeProducer",{producerId:this._micProducer.id}),this.emit("micEnd",{peerId:this.data.inputParams.peerId,audioTrack:null,type:"local"})}catch(e){this.emit("error",{code:"EID003",text:"Error disabling microphone!"})}this._micProducer=null}}async muteMic(){Ia.debug("muteMic()"),this._micProducer.pause();try{await this._cignal.request("pauseProducer",{producerId:this._micProducer.id}),this.emit("peerMuted",{peerId:this.data.inputParams.peerId,type:"local"})}catch(e){Ia.error("muteMic() | failed: %o",e),this.emit("error",{code:"EID004",text:"Error muting local microphone!"})}}async unmuteMic(){Ia.debug("unmuteMic()"),this._micProducer.resume();try{await this._cignal.request("resumeProducer",{producerId:this._micProducer.id}),this.emit("peerUnMuted",{peerId:this.data.inputParams.peerId,type:"local"})}catch(e){Ia.error("unmuteMic() | failed: %o",e),this.emit("error",{code:"EID005",text:"Error unmuting local microphone!"})}}async enableCam({deviceId:e=null,videoResolution:t,forceVp8:r,forceVp9:s,forceH264:i,h264Profile:a,forceFPS:n,enableWebcamLayers:o,numSimulcastStreams:c,videoBitRates:d}={}){if(Ia.debug("enableWebcam()"),!this.data.inputParams.produce)return Ia.debug("Produce status is set to false!"),{success:!1,error:!0,code:"REID004",text:"Error while trying to start Camera. Produce flag need to set to true while joining room in order to enable Camera."};if("connected"!==this._roomStatus)return Ia.debug("Room status is not connected yet!"),{success:!1,error:!0,code:"REID005",text:`Error while trying to start Camera as room not in connected status. Current room status:!${this._roomStatus}`,possibleReasons:"Did you forget to call joinRoom before enabling Camera? OR if you have already initiated the joinRoom process, then Camera will be enabled automatically once room join process completes."};if(this._webcamProducer)return Ia.debug("Camera is already active!"),{success:!1,warning:!0,code:"RWID003",text:"Error while trying to start Camera. Camera is already active!"};if(!this._device.canProduce("video"))return Ia.error("enableWebcam() | cannot produce video"),{success:!1,error:!0,code:"REID006",text:"Error while trying to start Camera. Camera couldnot be activated due to limitations on this device. If you think this device has a functional camera and the problem persists even after multiple retries, please contact technical support with the error code."};let p,l;["hd","vga","qvga"].includes(t)&&(this.data.inputParams.videoResolution=t,this._webcam.resolution=t),r&&"boolean"==typeof r&&(this.data.inputParams.forceVp8=r),s&&"boolean"==typeof s&&(this.data.inputParams.forceVp9=s),i&&"boolean"==typeof i&&(this.data.inputParams.forceH264=i),a&&["high","low"].includes(a.toLowerCase())&&(this.data.inputParams.h264Profile=a),n&&Number.isInteger(n)&&n<65&&n>5&&(this.data.inputParams.forceFPS=25),o&&"boolean"==typeof o&&(this.data.inputParams.enableWebcamLayers=o,this._enableWebcamLayers=o),c&&Number.isInteger(c)&&c<4&&c>0&&(this.data.inputParams.numSimulcastStreams=c,this._numSimulcastStreams=c),Array.isArray(d)&&d.length>=1&&d.length<=3&&d.every((e=>Number.isInteger(e)&&e>=75&&e<=800))?(Ia.debug("videoBitRates values are correct"),this.data.inputParams.videoBitRates=d):Ia.warn("videobitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[700,250,75]'");try{if(this._externalVideo)l={label:"external video"},this._webCamStream=await this._getExternalVideoStream(),p=this._webCamStream.getVideoTracks()[0].clone();else{e?(l=this._deviceList.videoDevices.find((t=>t.deviceId===e)),l||(Ia.warn("Selected deviceId:%s not found",e),l=this._deviceList.videoDevices[0])):l=this._deviceList.videoDevices[0],this._webcam.device=l;const{resolution:t}=this._webcam;if(!l)return Ia.error("No wencam device found! Can't start video!"),{success:!1,reason:"No Webcam available for starting video!"};e&&this.data.inputParams.videoDeviceId!==e&&(this.data.inputParams.videoDeviceId=e),Ia.debug("enableWebcam() | calling getUserMedia()"),this._webCamStream=await navigator.mediaDevices.getUserMedia({video:{deviceId:{ideal:l.deviceId},...xa[t],frameRate:{ideal:this.data.inputParams.forceFPS}}}),p=this._webCamStream.getVideoTracks()[0]}let t,r;const s={videoGoogleStartBitrate:1e3};if(Ia.debug("Current device codec options are:%O",this._device.rtpCapabilities.codecs),this._forceVP8){if(r=this._device.rtpCapabilities.codecs.find((e=>"video/vp8"===e.mimeType.toLowerCase())),!r)throw new Error("desired VP8 codec+configuration is not supported")}else if(this._forceH264){if("high"===this.data.inputParams.h264Profile?r=this._device.rtpCapabilities.codecs.find((e=>"video/h264"===e.mimeType.toLowerCase()&&"4d001f"===e.parameters["profile-level-id"])):"low"===this.data.inputParams.h264Profile&&(r=this._device.rtpCapabilities.codecs.find((e=>"video/h264"===e.mimeType.toLowerCase()&&"42e01f"===e.parameters["profile-level-id"]))),!r)throw new Error("desired H264 codec+configuration is not supported");Ia.debug("Selected h264 codec is:%O",r)}else if(this._forceVP9&&(r=this._device.rtpCapabilities.codecs.find((e=>"video/vp9"===e.mimeType.toLowerCase())),!r))throw new Error("desired VP9 codec+configuration is not supported");if(this._enableWebcamLayers){const e=this._device.rtpCapabilities.codecs.find((e=>"video"===e.kind));this._forceVP9&&r||"video/vp9"===e.mimeType.toLowerCase()?t=[{maxBitrate:5e6,scalabilityMode:this._webcamScalabilityMode||"L3T3_KEY"}]:(t=[{scaleResolutionDownBy:1,maxBitrate:1e3*this.data.inputParams.videoBitRates[0],scalabilityMode:this._webcamScalabilityMode||"L1T3"}],this._numSimulcastStreams>1&&t.unshift({scaleResolutionDownBy:2,maxBitrate:1e3*this.data.inputParams.videoBitRates[1],scalabilityMode:this._webcamScalabilityMode||"L1T3"}),this._numSimulcastStreams>2&&t.unshift({scaleResolutionDownBy:4,maxBitrate:1e3*this.data.inputParams.videoBitRates[2],scalabilityMode:this._webcamScalabilityMode||"L1T3"}))}this._webcamProducer=await this._sendTransport.produce({track:p,encodings:t,codecOptions:s,codec:r}),this._producers.set("video",{id:this._webcamProducer.id,deviceLabel:l.label,type:this._getWebcamType(l),paused:this._webcamProducer.paused,track:this._webcamProducer.track,rtpParameters:this._webcamProducer.rtpParameters,codec:this._webcamProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("videoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._webcamProducer.track,type:"local"}),this._webcamProducer.on("transportclose",(()=>{this._webcamProducer=null})),this._webcamProducer.on("trackended",(()=>{this.disableWebcam().catch((()=>{}))}))}catch(h){Ia.error("enableWebcam() | failed:%o",h),this.emit("error",{code:"EID011",text:"Enable Webcam failed!"}),p&&p.stop()}}async disableCam(){if(Ia.debug("disableWebcam()"),this._webcamProducer){this._webcamProducer.close(),this._producers.delete("video");try{await this._cignal.request("closeProducer",{producerId:this._webcamProducer.id}),this.emit("videoEnd",{peerId:this.data.inputParams.peerId,videoTrack:null})}catch(e){this.emit("error",{code:"EID012",text:"Error while closing server side producer!"})}this._webcamProducer=null}}async _updateWebcams(){Ia.debug("_updateWebcams()"),this._webcams=new Map,Ia.debug("_updateWebcams() | calling enumerateDevices()");const e=await navigator.mediaDevices.enumerateDevices();for(const i of e)"videoinput"===i.kind&&this._webcams.set(i.deviceId,i);const t=Array.from(this._webcams.values()),r=t.length,s=this._webcam.device?this._webcam.device.deviceId:void 0;Ia.debug("_updateWebcams() [webcams:%o]",t),0===r?this._webcam.device=null:this._webcams.has(s)||(this._webcam.device=t[0])}async _getExternalVideoStream(){if(this._externalVideoStream)return this._externalVideoStream;if(this._externalVideo.readyState<3&&await new Promise((e=>this._externalVideo.addEventListener("canplay",e))),this._externalVideo.captureStream)this._externalVideoStream=this._externalVideo.captureStream();else{if(!this._externalVideo.mozCaptureStream)throw new Error("video.captureStream() not supported");this._externalVideoStream=this._externalVideo.mozCaptureStream()}return this._externalVideoStream}_getWebcamType(e){return/(back|rear)/i.test(e.label)?(Ia.debug("_getWebcamType() | it seems to be a back camera"),"back"):(Ia.debug("_getWebcamType() | it seems to be a front camera"),"front")}async changeVideoInput({resolution:e,deviceId:t,fps:r}){if(this._webcamProducer){return await this._changeVideoInput({resolution:e,deviceId:t,fps:r})}return Ia.error("No webcam producer available!"),{success:!1,reason:"You are not sharing your camera yet. Camera Input can be changed to a new camera only when you are sharing an existing camera. "}}async _changeVideoInput({resolution:e,deviceId:t,fps:r}){Ia.info("_changeVideoInput() | Inside"),e&&["hd","vga","qvga"].includes(e)?this._webcam.resolution=e:Ia.warn("Invalid video resolution value "),r&&Number.isInteger(r)&&r<65&&r>5?this.data.inputParams.forceFPS=r:Ia.warn("forceFPS should be a number between 5 to 65, default value is 25 fps.");let s=this._deviceList.videoDevices.find((e=>t&&e.deviceId===t));if(!s)return Ia.error("The selected deviceId not found!"),{success:!1,reason:"Invalid deviceId!"};this._webcam.device=s;try{this._webCamStream.getVideoTracks().forEach((e=>e.stop())),this._webCamStream=null,Ia.debug("changeVideoInput() | calling getUserMedia()"),this._webCamStream=await navigator.mediaDevices.getUserMedia({video:{deviceId:{ideal:s.deviceId},...xa[this._webcam.resolution],frameRate:{ideal:this.data.inputParams.forceFPS}}});const e=this._webCamStream.getVideoTracks()[0];Ia.debug("The new video track is:%O",e),await this._webcamProducer.replaceTrack({track:e});let t=this._producers.get("video");return t.deviceLabel=s.label,t.type=this._getWebcamType(s),t.track=this._webcamProducer.track,Ia.debug("Updated producer values are:%O",t),this._producers.set("video",t),this.emit("videoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._webcamProducer.track,type:"local"}),{success:!0}}catch(i){return Ia.error("Error while changing input:%O",i),{success:!1,reason:"Couldn't change video input",error:i}}}async changeAudioInput({autoGainControl:e,echoCancellation:t,noiseSuppression:r,sampleRate:s,channelCount:i,deviceId:a}){if(this._micProducer){return await this._changeAudioInput({autoGainControl:e,echoCancellation:t,noiseSuppression:r,sampleRate:s,channelCount:i,deviceId:a})}return{success:!1,reason:"You are not sharing your mic yet. Mic Input can be changed to a new mic only when you are sharing an existing mic. "}}async _changeAudioInput({autoGainControl:e,echoCancellation:t,noiseSuppression:r,sampleRate:s,channelCount:i,deviceId:a}){e&&"boolean"==typeof e&&(this.data.inputParams.autoGainControl=e),t&&"boolean"==typeof t&&(this.data.inputParams.echoCancellation=Boolean(t)),r&&"boolean"==typeof r&&(this.data.inputParams.noiseSuppression=Boolean(r)),s&&Number.isInteger(s)&&s<64e3&&s>8e3&&(this.data.inputParams.sampleRate=s),i&&Number.isInteger(i)&&i>0&&i<3&&(this.data.inputParams.channelCount=i);let n=this._deviceList.audioDevices.find((e=>a&&e.deviceId===a));if(!n)return{success:!1,reason:"Invalid deviceId!"};this._mic.device=n,this._micStream&&this._micStream.getAudioTracks().forEach((e=>e.stop())),this._micStream=null;try{this._micStream=await navigator.mediaDevices.getUserMedia({audio:{deviceId:{ideal:n.deviceId},echoCancellation:this.data.inputParams.echoCancellation,noiseSuppression:this.data.inputParams.noiseSuppression,autoGainControl:this.data.inputParams.autoGainControl,sampleRate:this.data.inputParams.sampleRate,channelCount:this.data.inputParams.channelCount}});const e=this._micStream.getAudioTracks()[0];this._micProducer.replaceTrack({track:e});let t=this._producers.get("audio");return t.deviceLabel=n.label,t.track=this._micProducer.track,Ia.debug("Updated producer values are:%O",t),this._producers.set("audio",t),this.emit("micStart",{peerId:this.data.inputParams.peerId,audioTrack:this._micProducer.track,type:"local"}),{success:!0}}catch(Kn){return Ia.error("Error while changing input:%O",Kn),{success:!1,reason:"Couldn't change audio input",err:Kn}}}async enableShare({shareAudio:e=!1,enableSharingLayers:t=!0,shareBitRates:r=[2500,1250,500]}={}){if(Ia.debug("enableShare()"),!this.data.inputParams.produce)return Ia.debug("Produce status is set to false!"),{success:!1,error:!0,code:"REID003",text:"Error while trying to start screen share. Produce flag need to set to true while joining room in order to enable screen share."};if("connected"!==this._roomStatus)return Ia.debug("Room status is not connected yet!"),{success:!1,error:!0,code:"REID001",text:`Error while trying to start screen share as room not in connected status. Current room status:!${this._roomStatus}`,possibleReasons:"Did you forget to call joinRoom before enabling screen share? OR if you have already initiated the joinRoom process, then try enabling screen share after some seconds."};if(this._shareProducer)return Ia.debug("Screen share is already active!"),{success:!1,warning:!0,code:"RWID001",text:"Error while trying to start screen share. Screen share is already active!"};if(!this._device.canProduce("video"))return Ia.error("enableShare() | cannot produce video"),{success:!1,error:!0,code:"REID002",text:"Error while trying to start screen share. Screen share couldnot be activated due to limitations on this device. If you think this device is capable of screen share and the problem persists even after multiple retries, please contact technical support with the error code."};let s,i;this._enableSharingLayers="boolean"!=typeof t?Boolean(t):t,Array.isArray(r)&&r.length>=1&&r.length<=3&&r.every((e=>Number.isInteger(e)&&e>=500&&e<=2500))?this.data.inputParams.shareBitRates=r:this.data.inputParams.shareBitRates=[2500,1250,500];try{Ia.debug("enableShare() | calling getDisplayMedia()");const t=await navigator.mediaDevices.getDisplayMedia({audio:!!e,video:{displaySurface:"monitor",logicalSurface:!0,cursor:!0,width:{max:1920},height:{max:1080},frameRate:{max:30}}});if(!t)return Ia.error("Unable to capture screen."),void this.emit("error",{code:"EID013",text:"Error while trying to start screen share. Not able to capture screen!"});let r,a;i=t.getAudioTracks()[0],i&&(this._shareAudioProducer=await this._sendTransport.produce({track:i,codecOptions:this.data.inputParams.forcePCMU?void 0:{opusStereo:!1,opusDtx:!0,opusFec:!0,opusNack:!0},codec:this.data.inputParams.forcePCMU?this._device.rtpCapabilities.codecs.find((e=>"audio/pcmu"===e.mimeType.toLowerCase())):void 0}),this._producers.set("ssAudio",{id:this._shareAudioProducer.id,type:"shareAudio",paused:this._shareAudioProducer.paused,track:this._shareAudioProducer.track,rtpParameters:this._shareAudioProducer.rtpParameters,codec:this._shareAudioProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("ssAudioStart",{peerId:this.data.inputParams.peerId,audioTrack:this._shareAudioProducer.track,type:"local"})),s=t.getVideoTracks()[0];const n={videoGoogleStartBitrate:1e3};if(this._forceVP8){if(a=this._device.rtpCapabilities.codecs.find((e=>"video/vp8"===e.mimeType.toLowerCase())),!a)throw new Error("desired VP8 codec+configuration is not supported")}else if(this._forceH264){if("high"===this.data.inputParams.h264Profile?a=this._device.rtpCapabilities.codecs.find((e=>"video/h264"===e.mimeType.toLowerCase()&&"4d001f"===e.parameters["profile-level-id"])):"low"===this.data.inputParams.h264Profile&&(a=this._device.rtpCapabilities.codecs.find((e=>"video/h264"===e.mimeType.toLowerCase()&&"42e01f"===e.parameters["profile-level-id"]))),!a)throw new Error("desired H264 codec+configuration is not supported");Ia.debug("Selected h264 codec is:%O",a)}else if(this._forceVP9&&(a=this._device.rtpCapabilities.codecs.find((e=>"video/vp9"===e.mimeType.toLowerCase())),!a))throw new Error("desired VP9 codec+configuration is not supported");if(this._enableSharingLayers){const e=this._device.rtpCapabilities.codecs.find((e=>"video"===e.kind));this._forceVP9&&a||"video/vp9"===e.mimeType.toLowerCase()?r=[{maxBitrate:1e3*this.data.inputParams.shareBitRates[0],scalabilityMode:this._sharingScalabilityMode||"L3T3",dtx:!0}]:(r=[{scaleResolutionDownBy:1,maxBitrate:1e3*this.data.inputParams.shareBitRates[0],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}],this._numSimulcastStreams>1&&r.unshift({scaleResolutionDownBy:2,maxBitrate:1e3*this.data.inputParams.shareBitRates[1],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}),this._numSimulcastStreams>2&&r.unshift({scaleResolutionDownBy:4,maxBitrate:1e3*this.data.inputParams.shareBitRates[2],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}))}this._shareProducer=await this._sendTransport.produce({track:s,encodings:r,codecOptions:n,codec:a,appData:{share:!0}}),this._producers.set("ssVideo",{id:this._shareProducer.id,type:"shareVideo",paused:this._shareProducer.paused,track:this._shareProducer.track,rtpParameters:this._shareProducer.rtpParameters,codec:this._shareProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("ssVideoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._shareProducer.track,type:"local"}),this._shareProducer.on("transportclose",(()=>{this._shareProducer=null})),this._shareProducer.on("trackended",(()=>{this.disableShare().catch((()=>{}))}))}catch(a){Ia.error("enableShare() | failed:%o",a),"NotAllowedError"!==a.name&&this.emit("error",{code:"EID014",text:`Error while trying to start screen share. Error is: ${a}!`}),s&&s.stop()}}async disableShare(){if(Ia.debug("disableShare()"),!this._shareProducer)return Ia.warn("Screen share doesn't seem to be on!"),void this.emit("error",{code:"EID017",text:"Error while trying to stop screen share. Is the screen share on!"});if(this._shareProducer.close(),this._shareAudioProducer){this._shareAudioProducer.close();try{await this._cignal.request("closeProducer",{producerId:this._shareAudioProducer.id}),this.emit("ssAudioStop",{peerId:this.data.inputParams.peerId,videoTrack:null,type:"local"})}catch(e){this.emit("error",{code:"EID015",text:`Error while trying to stop screen share audio. Error is: ${e}!`})}}try{await this._cignal.request("closeProducer",{producerId:this._shareProducer.id}),this.emit("ssVideoStop",{peerId:this.data.inputParams.peerId,videoTrack:null,type:"local"})}catch(e){this.emit("error",{code:"EID016",text:`Error while trying to stop screen share video. Error is: ${e}!`})}this._shareAudioProducer=null,this._shareProducer=null}}const Aa=async e=>new Promise((t=>setTimeout((()=>t()),e))),ja=new Set(["240p","360p","480p","720p","1080p","1440p","2160p"]);function Na(e){return!!Array.isArray(e)&&e.every((e=>ja.has(e)))}const Ba=new Ut("utils-verifyFiles"),Fa=["mp4"];function $a(e,t){try{const r=new URL(e).pathname;return r.split(".").pop().toLowerCase()===t.toLowerCase()}catch{return!1}}const Ua=new TextEncoder,qa=new TextDecoder;function Va(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64("string"==typeof e?e:qa.decode(e),{alphabet:"base64url"});let t=e;t instanceof Uint8Array&&(t=qa.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return function(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);const t=atob(e),r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}class Wa extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class Ka extends Wa{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,t,r="unspecified",s="unspecified"){super(e,{cause:{claim:r,reason:s,payload:t}}),this.claim=r,this.reason=s,this.payload=t}}class Ha extends Wa{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,t,r="unspecified",s="unspecified"){super(e,{cause:{claim:r,reason:s,payload:t}}),this.claim=r,this.reason=s,this.payload=t}}class Ga extends Wa{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class za extends Wa{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class Ja extends Wa{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class Qa extends Wa{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class Xa extends Wa{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",t){super(e,t)}}function Ya(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function Za(e,t){return e.name===t}function en(e){return parseInt(e.name.slice(4),10)}function tn(e,t,r){switch(t){case"HS256":case"HS384":case"HS512":{if(!Za(e.algorithm,"HMAC"))throw Ya("HMAC");const r=parseInt(t.slice(2),10);if(en(e.algorithm.hash)!==r)throw Ya(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!Za(e.algorithm,"RSASSA-PKCS1-v1_5"))throw Ya("RSASSA-PKCS1-v1_5");const r=parseInt(t.slice(2),10);if(en(e.algorithm.hash)!==r)throw Ya(`SHA-${r}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!Za(e.algorithm,"RSA-PSS"))throw Ya("RSA-PSS");const r=parseInt(t.slice(2),10);if(en(e.algorithm.hash)!==r)throw Ya(`SHA-${r}`,"algorithm.hash");break}case"Ed25519":case"EdDSA":if(!Za(e.algorithm,"Ed25519"))throw Ya("Ed25519");break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":if(!Za(e.algorithm,t))throw Ya(t);break;case"ES256":case"ES384":case"ES512":{if(!Za(e.algorithm,"ECDSA"))throw Ya("ECDSA");const r=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}(t);if(e.algorithm.namedCurve!==r)throw Ya(r,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}!function(e,t){if(!e.usages.includes(t))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}(e,r)}function rn(e,t,...r){if((r=r.filter(Boolean)).length>2){const t=r.pop();e+=`one of type ${r.join(", ")}, or ${t}.`}else 2===r.length?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&null!=t&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}function sn(e,t,...r){return rn(`Key for the ${e} algorithm must be `,t,...r)}function an(e){return"CryptoKey"===e?.[Symbol.toStringTag]}function nn(e){return"KeyObject"===e?.[Symbol.toStringTag]}const on=e=>an(e)||nn(e),cn=(...e)=>{const t=e.filter(Boolean);if(0===t.length||1===t.length)return!0;let r;for(const s of t){const e=Object.keys(s);if(r&&0!==r.size)for(const t of e){if(r.has(t))return!1;r.add(t)}else r=new Set(e)}return!0};const dn=e=>{if("object"!=typeof(t=e)||null===t||"[object Object]"!==Object.prototype.toString.call(e))return!1;var t;if(null===Object.getPrototypeOf(e))return!0;let r=e;for(;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r};const pn=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:r}=function(e){let t,r;switch(e.kty){case"AKP":switch(e.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":t={name:e.alg},r=e.priv?["sign"]:["verify"];break;default:throw new za('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new za('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"EC":switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},r=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},r=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new za('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"OKP":switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new za('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;default:throw new za('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}(e),s={...e};return"AKP"!==s.kty&&delete s.alg,delete s.use,crypto.subtle.importKey("jwk",s,t,e.ext??(!e.d&&!e.priv),e.key_ops??r)},ln=(e,t,r,s,i)=>{if(void 0!==i.crit&&void 0===s?.crit)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!s||void 0===s.crit)return new Set;if(!Array.isArray(s.crit)||0===s.crit.length||s.crit.some((e=>"string"!=typeof e||0===e.length)))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;a=void 0!==r?new Map([...Object.entries(r),...t.entries()]):t;for(const n of s.crit){if(!a.has(n))throw new za(`Extension Header Parameter "${n}" is not recognized`);if(void 0===i[n])throw new e(`Extension Header Parameter "${n}" is missing`);if(a.get(n)&&void 0===s[n])throw new e(`Extension Header Parameter "${n}" MUST be integrity protected`)}return new Set(s.crit)},hn=(e,t)=>{if(void 0!==t&&(!Array.isArray(t)||t.some((e=>"string"!=typeof e))))throw new TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)};function un(e){return dn(e)&&"string"==typeof e.kty}let mn;const fn=async(e,t,r,s=!1)=>{mn||=new WeakMap;let i=mn.get(e);if(i?.[r])return i[r];const a=await pn({...t,alg:r});return s&&Object.freeze(e),i?i[r]=a:mn.set(e,{[r]:a}),a},gn=async(e,t)=>{if(e instanceof Uint8Array)return e;if(an(e))return e;if(nn(e)){if("secret"===e.type)return e.export();if("toCryptoKey"in e&&"function"==typeof e.toCryptoKey)try{return((e,t)=>{mn||=new WeakMap;let r=mn.get(e);if(r?.[t])return r[t];const s="public"===e.type,i=!!s;let a;if("x25519"===e.asymmetricKeyType){switch(t){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}a=e.toCryptoKey(e.asymmetricKeyType,i,s?[]:["deriveBits"])}if("ed25519"===e.asymmetricKeyType){if("EdDSA"!==t&&"Ed25519"!==t)throw new TypeError("given KeyObject instance cannot be used for this algorithm");a=e.toCryptoKey(e.asymmetricKeyType,i,[s?"verify":"sign"])}switch(e.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":if(t!==e.asymmetricKeyType.toUpperCase())throw new TypeError("given KeyObject instance cannot be used for this algorithm");a=e.toCryptoKey(e.asymmetricKeyType,i,[s?"verify":"sign"])}if("rsa"===e.asymmetricKeyType){let r;switch(t){case"RSA-OAEP":r="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":r="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":r="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":r="SHA-512";break;default:throw new TypeError("given KeyObject instance cannot be used for this algorithm")}if(t.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:r},i,s?["encrypt"]:["decrypt"]);a=e.toCryptoKey({name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:r},i,[s?"verify":"sign"])}if("ec"===e.asymmetricKeyType){const r=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(e.asymmetricKeyDetails?.namedCurve);if(!r)throw new TypeError("given KeyObject instance cannot be used for this algorithm");"ES256"===t&&"P-256"===r&&(a=e.toCryptoKey({name:"ECDSA",namedCurve:r},i,[s?"verify":"sign"])),"ES384"===t&&"P-384"===r&&(a=e.toCryptoKey({name:"ECDSA",namedCurve:r},i,[s?"verify":"sign"])),"ES512"===t&&"P-521"===r&&(a=e.toCryptoKey({name:"ECDSA",namedCurve:r},i,[s?"verify":"sign"])),t.startsWith("ECDH-ES")&&(a=e.toCryptoKey({name:"ECDH",namedCurve:r},i,s?[]:["deriveBits"]))}if(!a)throw new TypeError("given KeyObject instance cannot be used for this algorithm");return r?r[t]=a:mn.set(e,{[t]:a}),a})(e,t)}catch(Kn){if(Kn instanceof TypeError)throw Kn}let r=e.export({format:"jwk"});return fn(e,r,t)}if(un(e))return e.k?Va(e.k):fn(e,e,t,!0);throw new Error("unreachable")},bn=e=>e?.[Symbol.toStringTag],_n=(e,t,r)=>{if(void 0!==t.use){let e;switch(r){case"sign":case"verify":e="sig";break;case"encrypt":case"decrypt":e="enc"}if(t.use!==e)throw new TypeError(`Invalid key for this operation, its "use" must be "${e}" when present`)}if(void 0!==t.alg&&t.alg!==e)throw new TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){let s;switch(!0){case"verify"===r:case"dir"===e:case e.includes("CBC-HS"):s=r;break;case e.startsWith("PBES2"):s="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):s=!e.includes("GCM")&&e.endsWith("KW")?"unwrapKey":r;break;case"encrypt"===r:s="wrapKey";break;case"decrypt"===r:s=e.startsWith("RSA")?"unwrapKey":"deriveBits"}if(s&&!1===t.key_ops?.includes?.(s))throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${s}" when present`)}return!0},yn=(e,t,r)=>{e.startsWith("HS")||"dir"===e||e.startsWith("PBES2")||/^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(e)||/^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(e)?((e,t,r)=>{if(!(t instanceof Uint8Array)){if(un(t)){if(function(e){return"oct"===e.kty&&"string"==typeof e.k}(t)&&_n(e,t,r))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!on(t))throw new TypeError(sn(e,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if("secret"!==t.type)throw new TypeError(`${bn(t)} instances for symmetric algorithms must be of type "secret"`)}})(e,t,r):((e,t,r)=>{if(un(t))switch(r){case"decrypt":case"sign":if(function(e){return"oct"!==e.kty&&("AKP"===e.kty&&"string"==typeof e.priv||"string"==typeof e.d)}(t)&&_n(e,t,r))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"encrypt":case"verify":if(function(e){return"oct"!==e.kty&&void 0===e.d&&void 0===e.priv}(t)&&_n(e,t,r))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!on(t))throw new TypeError(sn(e,t,"CryptoKey","KeyObject","JSON Web Key"));if("secret"===t.type)throw new TypeError(`${bn(t)} instances for asymmetric algorithms must not be of type "secret"`);if("public"===t.type)switch(r){case"sign":throw new TypeError(`${bn(t)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw new TypeError(`${bn(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if("private"===t.type)switch(r){case"verify":throw new TypeError(`${bn(t)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw new TypeError(`${bn(t)} instances for asymmetric algorithm encryption must be of type "public"`)}})(e,t,r)},wn=async(e,t,r)=>{if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(((e,...t)=>rn("Key must be ",e,...t))(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}return tn(t,e,r),t},vn=async(e,t,r,s)=>{const i=await wn(e,t,"verify");((e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:r}=t.algorithm;if("number"!=typeof r||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}})(e,i);const a=((e,t)=>{const r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:e};default:throw new za(`alg ${e} is not supported either by JOSE or your javascript runtime`)}})(e,i.algorithm);try{return await crypto.subtle.verify(a,i,r,s)}catch{return!1}};async function Sn(e,t,r){if(!dn(e))throw new Ja("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new Ja('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new Ja("JWS Protected Header incorrect type");if(void 0===e.payload)throw new Ja("JWS Payload missing");if("string"!=typeof e.signature)throw new Ja("JWS Signature missing or incorrect type");if(void 0!==e.header&&!dn(e.header))throw new Ja("JWS Unprotected Header incorrect type");let s={};if(e.protected)try{const t=Va(e.protected);s=JSON.parse(qa.decode(t))}catch{throw new Ja("JWS Protected Header is invalid")}if(!cn(s,e.header))throw new Ja("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const i={...s,...e.header};let a=!0;if(ln(Ja,new Map([["b64",!0]]),r?.crit,s,i).has("b64")&&(a=s.b64,"boolean"!=typeof a))throw new Ja('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:n}=i;if("string"!=typeof n||!n)throw new Ja('JWS "alg" (Algorithm) Header Parameter missing or invalid');const o=r&&hn("algorithms",r.algorithms);if(o&&!o.has(n))throw new Ga('"alg" (Algorithm) Header Parameter value not allowed');if(a){if("string"!=typeof e.payload)throw new Ja("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new Ja("JWS Payload must be a string or an Uint8Array instance");let c=!1;"function"==typeof t&&(t=await t(s,e),c=!0),yn(n,t,"verify");const d=function(...e){const t=e.reduce(((e,{length:t})=>e+t),0),r=new Uint8Array(t);let s=0;for(const i of e)r.set(i,s),s+=i.length;return r}(Ua.encode(e.protected??""),Ua.encode("."),"string"==typeof e.payload?Ua.encode(e.payload):e.payload);let p;try{p=Va(e.signature)}catch{throw new Ja("Failed to base64url decode the signature")}const l=await gn(t,n);if(!(await vn(n,l,p,d)))throw new Xa;let h;if(a)try{h=Va(e.payload)}catch{throw new Ja("Failed to base64url decode the payload")}else h="string"==typeof e.payload?Ua.encode(e.payload):e.payload;const u={payload:h};return void 0!==e.protected&&(u.protectedHeader=s),void 0!==e.header&&(u.unprotectedHeader=e.header),c?{...u,key:l}:u}const Rn=e=>Math.floor(e.getTime()/1e3),Pn=86400,Cn=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,kn=e=>{const t=Cn.exec(e);if(!t||t[4]&&t[1])throw new TypeError("Invalid time period format");const r=parseFloat(t[2]);let s;switch(t[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":s=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":s=Math.round(60*r);break;case"hour":case"hours":case"hr":case"hrs":case"h":s=Math.round(3600*r);break;case"day":case"days":case"d":s=Math.round(r*Pn);break;case"week":case"weeks":case"w":s=Math.round(604800*r);break;default:s=Math.round(31557600*r)}return"-"===t[1]||"ago"===t[4]?-s:s},Tn=e=>e.includes("/")?e.toLowerCase():`application/${e.toLowerCase()}`,Dn=(e,t)=>"string"==typeof e?t.includes(e):!!Array.isArray(e)&&t.some(Set.prototype.has.bind(new Set(e)));async function En(e,t,r){const s=await async function(e,t,r){if(e instanceof Uint8Array&&(e=qa.decode(e)),"string"!=typeof e)throw new Ja("Compact JWS must be a string or Uint8Array");const{0:s,1:i,2:a,length:n}=e.split(".");if(3!==n)throw new Ja("Invalid Compact JWS");const o=await Sn({payload:i,protected:s,signature:a},t,r),c={payload:o.payload,protectedHeader:o.protectedHeader};return"function"==typeof t?{...c,key:o.key}:c}(e,t,r);if(s.protectedHeader.crit?.includes("b64")&&!1===s.protectedHeader.b64)throw new Qa("JWTs MUST NOT use unencoded payload");const i=function(e,t,r={}){let s;try{s=JSON.parse(qa.decode(t))}catch{}if(!dn(s))throw new Qa("JWT Claims Set must be a top-level JSON object");const{typ:i}=r;if(i&&("string"!=typeof e.typ||Tn(e.typ)!==Tn(i)))throw new Ka('unexpected "typ" JWT header value',s,"typ","check_failed");const{requiredClaims:a=[],issuer:n,subject:o,audience:c,maxTokenAge:d}=r,p=[...a];void 0!==d&&p.push("iat"),void 0!==c&&p.push("aud"),void 0!==o&&p.push("sub"),void 0!==n&&p.push("iss");for(const m of new Set(p.reverse()))if(!(m in s))throw new Ka(`missing required "${m}" claim`,s,m,"missing");if(n&&!(Array.isArray(n)?n:[n]).includes(s.iss))throw new Ka('unexpected "iss" claim value',s,"iss","check_failed");if(o&&s.sub!==o)throw new Ka('unexpected "sub" claim value',s,"sub","check_failed");if(c&&!Dn(s.aud,"string"==typeof c?[c]:c))throw new Ka('unexpected "aud" claim value',s,"aud","check_failed");let l;switch(typeof r.clockTolerance){case"string":l=kn(r.clockTolerance);break;case"number":l=r.clockTolerance;break;case"undefined":l=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:h}=r,u=Rn(h||new Date);if((void 0!==s.iat||d)&&"number"!=typeof s.iat)throw new Ka('"iat" claim must be a number',s,"iat","invalid");if(void 0!==s.nbf){if("number"!=typeof s.nbf)throw new Ka('"nbf" claim must be a number',s,"nbf","invalid");if(s.nbf>u+l)throw new Ka('"nbf" claim timestamp check failed',s,"nbf","check_failed")}if(void 0!==s.exp){if("number"!=typeof s.exp)throw new Ka('"exp" claim must be a number',s,"exp","invalid");if(s.exp<=u-l)throw new Ha('"exp" claim timestamp check failed',s,"exp","check_failed")}if(d){const e=u-s.iat;if(e-l>("number"==typeof d?d:kn(d)))throw new Ha('"iat" claim timestamp check failed (too far in the past)',s,"iat","check_failed");if(e<0-l)throw new Ka('"iat" claim timestamp check failed (it should be in the past)',s,"iat","check_failed")}return s}(s.protectedHeader,s.payload,r),a={payload:i,protectedHeader:s.protectedHeader};return"function"==typeof t?{...a,key:s.key}:a}const In=new Ut("Room"),xn={small:{width:{ideal:160},height:{ideal:120}},qvga:{width:{ideal:320},height:{ideal:240}},vga:{width:{ideal:640},height:{ideal:480}},hd:{width:{ideal:1280},height:{ideal:720}}};let Mn;const On=new class{constructor(){this.queue=new Map}push(e,t){this.queue.set(e,t)}get(e){return this.queue.get(e)}remove(e){this.queue.delete(e)}};class Ln extends Wt.EventEmitter{static async listDevices(){if(Mn)return In.info("Device list already exists:%O",Mn),{success:!0,deviceList:Mn};const e=await Ea();return e.success?(Mn=e.deviceList,{success:!0,deviceList:e.deviceList}):{success:!1,reason:e.reason}}static async init({sessionToken:e,roomId:t,peerId:r}={}){if(!e)throw new Error("Session token is required to join the room.");try{let s;In.info("session token:%s",e);try{const t=(new TextEncoder).encode("samvyo_tech_321"),{payload:r}=await En(e,t,{algorithms:["HS256"]});s=r,In.info("Decoded token:",s)}catch(Kn){throw In.error("JWT verification failed:",Kn),Kn instanceof Ha?new Error("Session token has expired"):Kn instanceof Ka?new Error("Session token not yet active"):new Error("Invalid session token: "+Kn.message)}if(!s||"object"!=typeof s)throw new Error("Invalid token format");const{data:i,signallingServerUrl:a}=s;if(!i||!a)throw new Error("Missing required token data");return r||(r=Rs()),t||(t=Ss()),new Ln({peerId:r,roomId:t,outputData:{sessionToken:e,innerSessionToken:i,signallingServerUrl:a}})}catch(s){throw In.error("Failed to initialize:",s.message),s}}constructor({peerId:e,roomId:t,outputData:r}){super(),this._closed=!1,this._roomStatus="initialised",this._roomDisplayName=null,this._running=!1,this._cignal=null,this._socket=null,this._sendTransport=null,this._recvTransport=null,this._device=new Ct.Device,this._webCamProducer=null,this._micProducer=null,this._shareProducer=null,this._shareAudioProducer=null,this._producers=new Map,this._consumers=new Map,this._peers=new Map,this._data={...r,inputParams:{peerId:e,roomId:t,roomType:"conferencing"}},this._micStream=null,this._webCamStream=null,this._webcam={device:null,resolution:"hd"},this._mic={device:null},this._deviceList=Mn||null,this._externalVideo=null,this._externalVideoStream=null,this._forceVP8=!1,this._forceH264=!1,this._forceVP9=!1,this._enableWebcamLayers=!0,this._numSimulcastStreams=3,this._enableSharingLayers=!0,this._client=Bt.parse(window.navigator.userAgent),this._routerRtpCapabilities=null,this._recordingStartedByMe={},this._cignalConnected=!1,this._reconnectionInitiated=!1,this._restartIceInProgressSendTransport=!1,this._restartIceInProgressRecvTransport=!1,this._activeSpeaker=null,this.initLocal()}get closed(){return this._closed}get data(){return this._data}set data(e){throw new Error("Setting the whole data object is not possible!")}get peers(){return this._peers}set peers(e){throw new Error("Setting the whole peers object is not possible!")}get transports(){return{produce:this._sendTransport,consume:this._recvTransport}}set transports(e){throw new Error("Setting of transport is not possible!")}get videoStream(){return this._webCamStream}get audioStream(){return this._micStream}get clientAgent(){return this._client}get activeParameters(){return this._data.inputParams}get deviceList(){return this._deviceList?this._deviceList:{videoDevices:[],audioDevices:[],audioOutputDevices:[]}}set deviceList(e){throw new Error("Setting of deviceList is not possible!")}get currentlyActiveSpeaker(){return this._activeSpeaker}set currentlyActiveSpeaker(e){throw new Error("Setting of currentActivespeaker is not possible!")}get roomDisplayName(){return this._roomDisplayName}set roomDisplayName(e){throw new Error("Setting of roomDisplayName is not possible!")}async initLocal(){const e=Ct.detectDevice();In.debug("The device is:%O",e),await this._initSocket()}async _initSocket(){let e=this;const t=this.data.signallingServerUrl.replace(/^(http|https):\/\//,""),r=`wss://${t}/?sessionToken=${this.data.sessionToken}&roomId=${this.data.inputParams.roomId}&peerId=${this.data.inputParams.peerId}&roomType=${this.data.inputParams.roomType}`;In.info(`Going to create a new socket! with address: ${t}`),this._socket=new vs(r,!0),this._listenToSocket(),this._socket.on("notify",(({type:e,title:t,message:r})=>{this.emit("notification",{eventType:e,eventText:`${t}: ${r}`,roomId:this.data.inputParams.roomId,peerId:this.data.inputParams.peerId})})),this._socket.on("roomStartedP2p",(e=>{In.info("P2P room successfully started"),this._running=!0})),this._socket.on("userError",(t=>{In.error("User Error happened with message:%O",t),e.emit("notification",{eventType:t.title,eventText:`${t.text}`})})),this._socket.on("validationAlert",(e=>{In.info("Validation alert happened")})),this._socket.on("alreadyActive",(({title:e,text:t})=>{this.emit("notification",{eventType:"alreadyActive",eventText:"This peer already has an active connection",roomId:this.data.inputParams.roomId,peerId:this.data.inputParams.peerId})})),this._socket.on("passwordDisabled",(()=>{In.info("password disabled by moderator!"),this.emit("notification",{eventType:"passwordDisabled",eventText:"Password for this room has been disabled by moderator",roomId:this.data.inputParams.roomId})})),this._socket.on("close",(({code:e,reason:t})=>{if(In.info(`socket closed with code ${e}`),4500!==e&&4100!==e){let r=t||"Connection to server closed unexpectedly! Trying to reconnect.";In.info(`socket close code is${e} with reason ${r}`)}else In.info("Socket is now closed!"),this.close()})),this._socket.on("connected",(async()=>{In.info("Socket connected"),e.pc&&e._sendTransport&&e._recvTransport?roomType===ha.P2P&&e.pc?(In.info("Socket seems to be reconnected in mid call! RestartIce needed for p2p call."),"failed"!==e.pc.iceConnectionState&&"disconnected"!==e.pc.iceConnectionState||e.restartICE()):(In.debug("Ice restarts for mediasoup transports for a joined peer"),e._sendTransport&&["Failed","disconnected"].includes(e._sendTransport.connectionState)?(In.debug("Restart ice for sendtransport"),e.restartIce(e._sendTransport.id,"send")):In.error("Send transport not available!"),e._recvTransport&&["Failed","disconnected"].includes(e._recvTransport.connectionState)?(In.debug("Restart ice for recvtransport"),e.restartIce(e._recvTransport.id,"recv")):In.error("Recv transport not available!")):(In.info("Connection getting connected for first time"),this.emit("initSuccess"))})),this._socket.on("defaultJoinStatus",(async e=>{In.info(" Socket defaultjoinstatus:%O",e)}))}_sendMessage(e){this._socket.send({usageType:"sdk",...e})}_listenToSocket(){this._socket.on("message",(e=>{try{switch("currentlyActiveSpeaker"===e.id||"allStats"===e.id||In.info("message in Room is:%O",e),e.id){case"chatMessage":this.processChatMessage(e);break;case"customMessage":this.processCustomMessage(e);break;case"existingParticipants":this.onExistingParticipants(e);break;case"newPeerJoin":this.onNewPeer(e);break;case"recordingError":this.handleRecordingErrors(e);break;case"moderatorAuthentication":this.authenticateUser(e);break;case"authenticationRequested":this.authenticationRequested(e);break;case"toggleMyMic":this.toggleMyMic(e);break;case"toggleMyCamera":this.toggleMyCamera(e);break;case"logMeOut":this.logMeOutNew(e);break;case"userAlreadyAuthenticated":this.hideUserAuthenticationDialog(e);break;case"peerLeft":this.peerLeft(e);break;case"recordingStarted":this.setRecordingStatusStarted(e);break;case"recordingStopped":this.setRecordingStatusEnded(e);break;case"startDefaultRecording":this.startRecording(e);break;case"mediaToggled":this.mediaToggled(e);break;case"processingStarted":this.handleProcessingStart(e);break;case"processingCompleted":this.handleProcessingCompletion(e);break;case"processingError":this.handleProcessingError(e);break;case"createTransportResponse":this.handleCreateTransportRequest(e);break;case"connectTransportResponse":this.handleConnectTransportRequest(e);break;case"connectRecvTransportResponse":this.handleConnectRecvTransportRequest(e);break;case"sendTrackResponse":this.handleSendTrackRequest(e);break;case"recvTrackResponse":this.handleRecvTrackRequest(e);break;case"roomClosedByModerator":this.leaveRoomCommon(),this.roomClosed();break;case"currentlyActiveSpeaker":this.setCurrentlyActiveSpeaker(e);break;case"restartIceResponse":this.restartIceResponse(e);break;case"consumerClosed":this.closeConsumer(e);break;case"handRaise":this.handleHandRaise(e);break;case"updateCId":this.updateCId(e);break;case"upgradeParticipant":this.handleUpgradeParticipant(e);break;case"downgradeParticipant":this.handleDowngradeParticipant(e);break;case"switchMicOff":this.handleSwitchMicOff(e);break;case"screenShareLimitReached":this.handleScreenShareLimitReached(e);break;case"upgradeLimitReached":this.handleUpgradeLimitReached(e);break;case"modUpgradeReq":this.handleModUpgradeReq(e);break;case"lockUnlockRoom":this.handleLockUnlockRoom(e);break;case"peersWaiting":this.handlePeersWaiting(e);break;case"remotePeerJoin":this.handleRemotePeerJoin(e);break;case"offer":In.debug("inside offer"),this.handleOffer(e);break;case"answer":In.debug("inside answer"),this.handleAnswer(e);break;case"candidate":In.debug("inside handle candidate"),this.handleCandidate(e.candidate);break;case"p2pRoomClosed":In.debug("inside p2p room close"),this.leaveRoomNewP2p("leaveAndCloseRoom");break;case"p2pUserLeft":In.debug("inside p2p user left"),this.userLeftRoom(e);break;case"iceRestart":this.handleIceRestart(e);break;case"iceRestarted":this.handleIceRestartResponse(e);break;case"screenShareP2p":this.handleScreenShareP2p(e);break;default:In.warn("Unrecognized message:%o",e)}}catch(Kn){In.error("listentomessage:%O",Kn)}}))}joinRoom=async({peerName:e=null,produce:t=!0,produceAudio:r=!0,produceVideo:s=!0,consume:i=!0,videoResolution:a="hd",forceVp8:n=!1,forceVp9:o=!1,forceH264:c=!1,h264Profile:d="high",forcePCMU:p=!1,forcePCMA:l=!1,forceFPS:h=25,enableWebcamLayers:u=!0,numSimulcastStreams:m=3,autoGainControl:f=!0,echoCancellation:g=!0,noiseSuppression:b=!0,sampleRate:_=44e3,channelCount:y=1,videoBitRates:w=[700,250,75],share:v=!1,shareAudio:S=!1,enableSharingLayers:R=!0,shareBitRates:P=[2500,1250,500],audioDeviceId:C=null,videoDeviceId:k=null,peerType:T="participant",roomType:D=ha.CONFERENCING,authenticationRequired:E=!1,password:I=null,roomDisplayName:x=null}={})=>{In.info("Going to join room"),["hd","vga","qvga"].includes(a)||(In.warn("Invalid video resolution value. setting it to default value of 'hd' "),a="hd"),"boolean"!=typeof t&&(In.warn("Produe should either be true or false"),t=Boolean(t)),"boolean"!=typeof r&&(In.warn("ProduceAudio should either be true or false"),r=Boolean(r)),"boolean"!=typeof s&&(In.warn("ProduceVideo should either be true or false"),s=Boolean(s)),"boolean"!=typeof i&&(In.warn("Consume should either be true or false"),i=Boolean(i)),"boolean"!=typeof n&&(In.warn("forceVp8 should either be true or false"),n=Boolean(n)),"boolean"!=typeof o&&(In.warn("forceVp9 should either be true or false"),o=Boolean(o)),"boolean"!=typeof c&&(In.warn("forceH264 should either be true or false"),c=Boolean(c)),["high","low"].includes(d.toLowerCase())||(In.warn("h264Profile should either be 'high' or 'low'"),d="high"),(!Number.isInteger(h)||Number.isInteger(h)&&(h>65||h<5))&&(In.warn("forceFPS should be a number between 5 to 65, default value is 25 fps."),h=25),"boolean"!=typeof u&&(In.warn("enableWebcamLayers should either be true or false"),u=Boolean(u)),(!Number.isInteger(m)||Number.isInteger(m)&&(m>3||m<1))&&(In.warn("numSimulcastStreams should be a number between 1 to 3, default value is 3."),m=3),Array.isArray(w)&&w.length>=1&&w.length<=3&&w.every((e=>Number.isInteger(e)&&e>=75&&e<=800))?In.debug("videoBitRates values are correct"):(In.warn("videobitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[700,250,75]'"),w=[700,250,75]),"boolean"!=typeof p&&(In.warn("forcePCMU should either be true or false"),p=Boolean(p)),"boolean"!=typeof l&&(In.warn("forcePCMA should either be true or false"),l=Boolean(l)),"boolean"!=typeof f&&(In.warn("autoGainControl should either be true or false"),f=Boolean(f)),"boolean"!=typeof g&&(In.warn("echoCancellation should either be true or false"),g=Boolean(g)),"boolean"!=typeof b&&(In.warn("noiseSuppression should either be true or false"),b=Boolean(b)),(!Number.isInteger(_)||Number.isInteger(_)&&(_>64e3||_<8e3))&&(In.warn("sampleRate should be a number between 8000 to 64000, default value is 44000 Khz."),_=44e3),(!Number.isInteger(y)||Number.isInteger(y)&&(y>2||y<1))&&(In.warn("sampleRate should be a number between 1 to 2, default value is 1, which is a mono audio."),y=1),"boolean"!=typeof v&&(In.warn("share should either be true or false"),v=Boolean(v)),"boolean"!=typeof S&&(In.warn("shareAudio should either be true or false"),S=Boolean(S)),"boolean"!=typeof R&&(In.warn("enableSharingLayers should either be true or false"),R=Boolean(R)),Array.isArray(P)&&P.length>=1&&P.length<=3&&P.every((e=>Number.isInteger(e)&&e>=500&&e<=2500))?In.debug("shareBitRates values are correct"):(In.warn("sharebitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[2500,1250,500]'"),P=[2500,1250,500]),["moderator","participant","attendee"].includes(T)?In.debug("peerType is valid:%s",T):(T="participant",In.debug("peerType is invalid:%s. By default set to: participant",T)),await this.listDevicesInternal(),this._videoResolution=a,this._forceVP8=Boolean(n),this._forceH264=Boolean(c),this._forceVP9=Boolean(o),this._enableWebcamLayers=Boolean(u),this._numSimulcastStreams=m,this._enableSharingLayers=Boolean(R);try{e||(e=Ta()),this.data.inputParams={...this.data.inputParams,peerName:e,produce:t,produceAudio:r,produceVideo:s,consume:i,videoResolution:a,forceVp8:n,forceVp9:o,forceH264:c,h264Profile:d,forceFPS:h,forcePCMU:p,forcePCMA:l,enableWebcamLayers:u,numSimulcastStreams:m,autoGainControl:f,echoCancellation:g,noiseSuppression:b,sampleRate:_,channelCount:y,videoBitRates:w,share:v,shareAudio:S,enableSharingLayers:R,shareBitRates:P,audioDeviceId:C,videoDeviceId:k,peerType:T,roomType:D,authenticationRequired:E,password:I,roomDisplayName:x},In.info("input params are:%O",this.data.inputParams);const M={id:"joinRoom",type:"r",peerId:this.data.inputParams.peerId,participantType:"attendee"===T?"viewer":T,roomType:D,roomDisplayName:x||`room-${1e5+Math.round(9e5*Math.random())}`,browser:this._client,name:this.data.inputParams.peerName,room:this.data.inputParams.roomId,authenticationRequired:E,isRoomPassword:!!I,roomPassword:I||null,usageType:"sdk"};this._sendMessage(M)}catch(M){return In.error("Failed to join room:",M.message),{success:!1,reason:M.message}}};authenticateUser=e=>{In.info("Moderator authentication requested:%O",e),this.emit("moderatorAuthentication",{moderatorName:e.moderatorName,requesterName:e.requesterName,requesterPeerId:e.requesterPeerId,text:e.title})};authenticationRequested=e=>{In.info("Moderator authentication requested:%O",e),this.emit("authenticationRequested",{requesterName:e.requesterName,requesterPeerId:this.data.inputParams.peerId,text:e.title})};allowRoomJoin=e=>{if(!e)return In.error("peerId can't be undefined!"),{success:!1,reason:"PeerId can't be undefined"};In.info("Allow user to join room:%O",e);let t={id:"userAuthenticated",peerId:e,roomName:this.data.inputParams.roomId,moderator:this.data.inputParams.peerId};this._sendMessage(t)};denyRoomJoin=e=>{if(!e)return In.error("peerId can't be undefined!"),{success:!1,reason:"PeerId can't be undefined"};In.info("Deny user to join room:%O",e);let t={id:"userDenied",peerId:e,roomName:this.data.inputParams.roomId,moderator:this.data.inputParams.peerId};this._sendMessage(t)};hideUserAuthenticationDialog=e=>{In.debug("authentication already done message:%o",e),this.emit("moderatorAuthStatus",{requesterId:e.requesterId,moderatorActed:e.peerId})};onNewPeer(e){const{peerId:t,displayName:r,participantType:s}=e;this._peers.set(t,{displayName:r,participantType:s,consumers:[]}),this.emit("newPeer",{peerId:t,peerName:r,type:this.data.inputParams.peerId===t?"local":"remote",peerRole:s})}async onExistingParticipants(e){if(In.debug("Onexisting participant message:%O",e),this._routerRtpCapabilities=e.routerRtpCapabilities,this._roomStatus="connected",this._roomDisplayName=e.roomDisplayName,this._running=!0,this._socket._roomJoined=!0,this.emit("newPeer",{peerId:this.data.inputParams.peerId,peerName:this.data.inputParams.peerName,type:"local",peerRole:this.data.inputParams.peerType}),this.data.inputParams.produce?await this._createSendTransport():In.debug("Produce is false!"),this.data.inputParams.consume){await this._createRecvTransport();let t=this;e.peers&&e.peers.length>0&&e.peers.forEach((e=>{t.emit("newPeer",{peerId:e.peerId,peerName:e.name,type:"remote",peerRole:e.participantType})}))}else In.debug("Consume is false!")}sendCustomMessage=(e,t="general",r=null,s,i,a={})=>{const n={id:"customMessage",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,data:e,type:t,recieverPeerId:r,senderType:s,messageType:i,customData:a};In.debug("Room sendCustomMessage",n),this._sendMessage(n)};processCustomMessage=e=>{In.debug("Room processCustomMessage",e),this.emit("customMessage",e)};updateCId=e=>{In.debug("Received updateCId message",e),e.targetPeerId!==this.data.inputParams.peerId&&e.targetPeerId||this.emit("updateCId",{message:e,cId:e.cId,peerId:this.data.inputParams.peerId,isMyCId:e.targetPeerId===this.data.inputParams.peerId})};setCurrentlyActiveSpeaker(e){const{peerId:t,volume:r}=e.activeSpeaker;this._activeSpeaker=e.activeSpeaker,this.emit("activeSpeaker",{peerId:t,volume:r})}_createSendTransport=async()=>{In.debug("Room _createSendTransport");try{this._device.loaded||(In.debug("Room _createSendTransport","Going to load device with routerrtpcapabilities"),await this._device.load({routerRtpCapabilities:this._routerRtpCapabilities}));let e="send";this._sendTransport||this._sendMessage({id:"createTransport",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,direction:e})}catch(Kn){In.error("Room _createSendTransport",Kn)}};_createRecvTransport=async()=>{this._device.loaded||(In.debug("loading device for creating recv transport"),await this._device.load({routerRtpCapabilities:this._routerRtpCapabilities}));this._recvTransport||(In.debug("receive transport created"),this._sendMessage({id:"createTransport",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,direction:"recv"}))};handleCreateTransportRequest=async e=>{In.debug("Room handleCreateTransportRequest():%O",e);let t,{transportOptions:r,direction:s}=e;try{if("recv"===s)t=await this._device.createRecvTransport(r),In.debug("Room",`handleCreateTransportRequest() recv transport created ${t.id}`),this._recvTransport=t,this.handleRecvTransportListeners();else{if("send"!==s)throw new Error(`bad transport 'direction': ${s}`);t=await this._device.createSendTransport(r),In.debug("Room",`handleCreateTransportRequest() send transport created [id:%s]${t.id}`),this._sendTransport=t,this.handleSendTransportListeners(),this.produceMedia()}}catch(i){}};handleSendTransportListeners=()=>{this._sendTransport.on("connect",this.handleTransportConnectEvent),this._sendTransport.on("produce",this.handleTransportProduceEvent);let e=this;this._sendTransport.on("connectionstatechange",(async t=>{if(In.debug(`ConferenceRoom sendTransport connectionState ${t} & socketconnection state ${this._socket._ws.readyState}`),"failed"===t||"disconnected"===t)if(1===this._socket._ws.readyState)e.restartIce(this._sendTransport.id,"send");else{for(;1!==this._socket._ws.readyState;)In.debug(`socket not yet ready with state- ${this._socket._ws.readyState}`),await Aa(1500);"connected"===this._roomStatus&&this.restartIce(this._sendTransport.id,"send")}In.debug("ConferenceRoom",`send transport connection state change [state:%s]${t}`)}))};handleTransportConnectEvent=({dtlsParameters:e},t,r)=>{try{const r=e=>{In.debug("connect-transport action"),t(),On.remove("connectTransport")};On.push("connectTransport",r);let s={id:"connectTransport",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,transportId:this._sendTransport.id,dtlsParameters:e,direction:"send"};this._sendMessage(s)}catch(s){In.error("handleTransportConnectEvent() failed [error:%o]",s),r(s)}};handleTransportProduceEvent=({kind:e,rtpParameters:t,appData:r},s,i)=>{try{const i=e=>{In.debug("handleTransportProduceEvent callback [data:%o]",e),s({id:e.producerId}),On.remove("produce")};On.push("produce",i);let a="cam-audio"===r.mediaTag&&void 0!==this.data.inputParams.audioStatus&&!this.data.inputParams.audioStatus;In.debug(`handleTransportProduceEvent() | pause status->${a}`);let n={id:"sendTrack",transportId:this._sendTransport.id,peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,kind:e,rtpParameters:t,paused:a,appData:r,clientOs:this._client.os.name,browser:this._client.browser};this._sendMessage(n)}catch(a){In.error("handleTransportProduceEvent() failed [error:%o]",a),i(a)}};produceMedia=async()=>{this.data.inputParams.produce?(this.data.inputParams.produceAudio?this.enableMic({deviceId:this.data.inputParams.audioDeviceId?this.data.inputParams.audioDeviceId:null}):In.debug("No need to produce audio!"),this._device.canProduce("video")&&(this.data.inputParams.produceVideo?this.enableCam({deviceId:this.data.inputParams.videoDeviceId?this.data.inputParams.videoDeviceId:null}):In.debug("No need to produce video!"),this.data.inputParams.share&&this.enableShare({shareAudio:this.data.inputParams.shareAudio,enableSharingLayers:this._enableSharingLayers,shareBitRates:this.data.inputParams.shareBitRates}))):In.warn("produce is false!")};handleRecvTransportListeners=async()=>{this._recvTransport.on("connect",this.handleRecvTransportConnectEvent);let e=this;this._recvTransport.on("connectionstatechange",(async t=>{if(In.debug(`ConferenceRoom recvTransport connectionState ${t} & socketconnection state ${this._socket._ws.readyState}`),"failed"===t||"disconnected"===t)if(1===this._socket._ws.readyState)e.restartIce(this._recvTransport.id,"recv");else{for(;1!==this._socket._ws.readyState;)In.debug(`socket not yet ready with state- ${this._socket._ws.readyState}`),await Aa(1e3);"connected"===this._roomStatus&&e.restartIce(this._recvTransport.id,"recv")}In.debug("ConferenceRoom",`Recv transport connection state change [state:%s]${t}`)}));let t={id:"transportsAvailable",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,rtpCapabilities:this._device.rtpCapabilities};this._sendMessage(t)};handleRecvTransportConnectEvent=({dtlsParameters:e},t,r)=>{try{const r=e=>{In.debug("ConferenceRoom","connect-recv-transport action"),t(),On.remove("connectRecvTransport")};On.push("connectRecvTransport",r);let s={id:"connectTransport",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,transportId:this._recvTransport.id,dtlsParameters:e,direction:"recv"};this._sendMessage(s)}catch(s){In.error("handleTransportConnectEvent() failed [error:%o]",s),r(s)}};handleRecvTrackRequest=async e=>{if(In.debug("Room handleRecvTrackRequest",e),!this.data.inputParams.consume)return void In.warn("I do not want to consume");let{senderPeerId:t,mediaTag:r,sender:s,audioStatus:i,videoStatus:a,senderParticipantType:n,type:o,producerPaused:c,...d}=e;In.debug("New consumer created",d),d.id=d.consumerId,delete d.consumerId,In.debug("ConferenceRoom",`senderPeerId is ->${t}`);let p=await this._recvTransport.consume({...d,streamId:`${t}-${"screen-video"===r||"screen-audio"===r?"share":"mic-webcam"}`,appData:{peerId:t,mediaTag:r}});for(;this._recvTransport&&"connected"!==this._recvTransport.connectionState;)In.debug(`recv transport connstate${this._recvTransport.connectionState}`),await Aa(100);this._consumers.set(p.id,p),p.on("transportclose",(()=>{this._consumers.delete(p.id)}));const{spatialLayers:l,temporalLayers:h}=Ct.parseScalabilityMode(p.rtpParameters.encodings[0].scalabilityMode),u=this._peers.get(this.data.inputParams.peerId);In.debug(`Consumer created for sender peerId ${t} for kind ${p.kind} for receiver peerId ${this.data.inputParams.peerId}`),In.info("The old peer data is :%O",u),u?(u["screen-video"===r||"screen-audio"===r?`ss${p.kind}`:p.kind]={consumerId:p.id,type:o,locallyPaused:!1,remotelyPaused:c,rtpParameters:p.rtpParameters,spatialLayers:l,temporalLayers:h,preferredSpatialLayer:l-1,preferredTemporalLayer:h-1,priority:1,codec:p.rtpParameters.codecs[0].mimeType.split("/")[1],track:p.track,share:"screen-video"===r||"screen-audio"===r},In.info("The new peer data is :%O",u),this._peers.set(this.data.inputParams.peerId,u)):(In.info("Peer not found!"),this._peers.set(this.data.inputParams.peerId,{["screen-video"===r||"screen-audio"===r?`ss${p.kind}`:p.kind]:{consumerId:p.id,type:o,locallyPaused:!1,remotelyPaused:c,rtpParameters:p.rtpParameters,spatialLayers:l,temporalLayers:h,preferredSpatialLayer:l-1,preferredTemporalLayer:h-1,priority:1,codec:p.rtpParameters.codecs[0].mimeType.split("/")[1],track:p.track,share:"screen-video"===r||"screen-audio"===r}})),await this.resumeConsumer(p),In.debug("Going to emit mic start / videostart"),"audio"===p.kind?"screen-audio"===r?this.emit("ssAudioStart",{peerId:t,audioTrack:p.track,type:"remote"}):this.emit("micStart",{peerId:t,audioTrack:p.track,type:"remote"}):"video"===p.kind&&("screen-video"===r?this.emit("ssVideoStart",{peerId:t,videoTrack:p.track,type:"remote"}):this.emit("videoStart",{peerId:t,videoTrack:p.track,type:"remote"}))};resumeConsumer=async e=>{if(e){In.debug("resume consumer",e.appData.peerId,e.appData.mediaTag);try{let t={id:"resumeConsumer",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,consumerId:e.id};this._sendMessage(t),await e.resume()}catch(t){}}};handleConnectTransportRequest=async e=>{In.debug("handleTransportConnectRequest()");try{const t=On.get("connectTransport");if(!t)throw new Error("transport-connect action was not found");await t(e)}catch(t){}};handleConnectRecvTransportRequest=async e=>{In.debug("handleTransportConnectRequest()");try{const t=On.get("connectRecvTransport");if(!t)throw new Error("recv transport-connect action was not found");await t(e)}catch(t){}};handleSendTrackRequest=async e=>{In.debug("ConferenceRoom","handleProduceRequest()");try{const t=On.get("produce");if(!t)throw new Error("produce action was not found");await t(e)}catch(t){In.error("handleProduceRequest() failed [error:%o]",t)}};mediaToggled=e=>{switch(In.debug("Media Toggled message:%O",e),e.type){case"video":In.debug(`mediaToggled() | inside case video${e.videoStatus}`);break;case"audio":In.debug(`mediaToggled() | inside case audio${e.videoStatus}`),e.audioStatus?this.emit("peerUnMuted",{peerId:e.peerId,type:"remote"}):this.emit("peerMuted",{peerId:e.peerId,type:"remote"})}};closeConsumer=e=>{let{consumerId:t}=e;const r=this._consumers.get(t);if(!r)return void In.warn("Consumer with id not found!:%s",t);const{peerId:s,mediaTag:i}=r.appData;In.debug("Consumer closed for consumerId:%s, type:%s, appData:%o",t,r?.kind,r.appData);let a="screen-audio"===i||"screen-video"===i?`ss${r.kind}`:r.kind;r.close(),this._consumers.delete(t);let n=this._peers.get(this.data.inputParams.peerId);In.debug("Peer data before deletion:%O",n),n[a]&&n[a].consumerId===t&&delete n[a],In.debug("Peer data after deletion:%O",n),this._peers.set(this.data.inputParams.peerId,n),"audio"===r?.kind?(In.debug("Going to emit micEnd, consumer closed for audio"),"screen-audio"===i?this.emit("ssAudioStop",{peerId:s,track:null,type:"remote"}):this.emit("micEnd",{peerId:s,track:null,type:"remote"})):"video"===r?.kind&&(In.debug("Going to emit videoEnd, consumer closed for video"),"screen-video"===i?this.emit("ssVideoStop",{peerId:s,track:null,type:"remote"}):this.emit("videoEnd",{peerId:s,track:null,type:"remote"}))};peerLeft=e=>{In.debug("Peer Left message is:%o",e);let{peerId:t}=e;this._peers.delete(t),this.emit("peerLeft",{peerId:t})};roomClosed=()=>{In.info("room closed by Moderator"),this._peers=null,this.emit("roomClosed",{roomId:this.data.inputParams.roomId})};close(){this._closed||(this._closed=!0,this._socket=null,this.data.inputParams={},In.info("Room close()"),this._sendTransport&&this._sendTransport.close(),this._recvTransport&&this._recvTransport.close(),this._roomStatus="closed",this._running=!1)}async leaveRoom(){In.debug("Leave room is called!!"),"connected"===this._roomStatus?(this._sendMessage({id:"leaveRoomNew",peerId:this.data.inputParams.peerId,roomLeaveType:"client"}),this.leaveRoomCommon()):In.error("The room state is:%s",this._roomStatus)}async closeRoom(){"connected"===this._roomStatus?(this._sendMessage({id:"leaveAndCloseRoom",peerId:this.data.inputParams.peerId,roomCloseType:"client"}),this.leaveRoomCommon()):In.error("The room state is:%s",this._roomStatus)}leaveRoomCommon=()=>{this._sendTransport&&(this._sendTransport.close(),this._sendTransport=null),this._recvTransport&&(this._recvTransport.close(),this._recvTransport=null),this._webCamStream&&this._webCamStream.getVideoTracks().forEach((e=>{e.stop(),In.debug("Video Track stopped")})),this._micStream&&this._micStream.getAudioTracks().forEach((e=>{e.stop(),In.debug("Mic Track stopped")})),this._roomStatus="closed",this._running=!1,this._routerRtpCapabilities=null};async listDevicesInternal(){if(navigator.mediaDevices.ondevicechange=async e=>{let t=await Da();In.info("Media devices changed!:%O",t),t.audioDevices&&t.audioDevices.length>0&&(this._deviceList.audioDevices=t.audioDevices),t.videoDevices&&t.videoDevices.length>0&&(this._deviceList.videoDevices=t.videoDevices),t.audioDevices&&t.audioDevices.length>0&&(this._deviceList.audioOutputDevices=t.audioDevicesOutput),Mn=this._deviceList,this.emit("deviceListUpdated")},!this._deviceList){const e=await Ea();if(e.success)return this._deviceList=e.deviceList,void(Mn=this._deviceList)}}restartIce=async(e,t)=>{if("send"===t&&"connected"===this._sendTransport.connectionState||"recv"===t&&"connected"===this._recvTransport.connectionState)return void In.debug("no need to restart ICE as transport now connected");In.debug("websocket is ready and connectionstate is still disconnected, therefore going to restart ICE");let r={id:"restartIce",transportId:e,roomName:this.data.inputParams.roomId,peerId:this.data.inputParams.peerId};this._sendMessage(r)};restartIceResponse=e=>{In.debug("restart ICE response:%o",e);let{transportId:t,iceParameters:r}=e;this._sendTransport&&this._sendTransport.id===t?this._sendTransport.restartIce({iceParameters:r}):this._recvTransport&&this._recvTransport.id===t&&this._recvTransport.restartIce({iceParameters:r})};startRecording=({recordingType:e=null,outputType:t=null,outputQualities:r=null}={})=>{In.debug("recording type requested is:%s,outputType:%s, outputQualties:%o",e,t,r);const s=!e||"av"!==e?.toLowerCase()&&"audiovideo"!==e?.toLowerCase()?"mergedA":"mergedAV";if((!t||"hls"!==t.toLowerCase()&&"mp4"!==t.toLowerCase())&&t)return In.error("Invalid outut type"),{success:!1,reason:`Invalid outputType: ${t}. `};if(t&&"hls"===t.toLowerCase()&&r&&!Na(r))return In.error("Invalid outut qualities"),{success:!1,reason:`Invalid outputQualities: ${JSON.stringify(r)}. Allowed values are ${Array.from(ja).join(", ")}.`};let i={id:"startRecording",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,url:window.location.hostname,type:ma,recordingStrategy:s,outputQualities:r,outputType:t?.toLowerCase()};this._sendMessage(i),this._recordingStartedByMe={...this._recordingStartedByMe,"main-room":{recordingNo:null}}};stopRecording=()=>{In.debug("going to stop recording for recordingStartedByMe:%o",this._recordingStartedByMe);let e="main-room";if(!this._recordingStartedByMe[e])return{success:!1,error:!0,code:"RRID001",text:"Error while trying to stop recording. Either the recording has not been started yet Or The same user need to stop recording who started it."};{let t={id:"stopRecording",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,recordingNo:this._recordingStartedByMe[e].recordingNo,type:ma};this._sendMessage(t),delete this._recordingStartedByMe[e],this.emit("recordingEnded",{peerId:this.data.inputParams.peerId})}};setRecordingStatusStarted=e=>{In.debug("Recording/Streaming started by moderator!!:%O",e);let{breakOutRoom:t,recordingStartTime:r,recordingNo:s,type:i}=e;[ma,fa].includes(i)&&(this._recordingStartedByMe["main-room"]?(In.debug("This recording has been started by me."),this._recordingStartedByMe["main-room"].recordingNo=s,this.emit("recordingStarted",{peerId:this.data.inputParams.peerId,startTime:r})):this.emit("recordingStarted",{startTime:r}))};setRecordingStatusEnded=e=>{In.debug("Recording ended by moderator!!, data:%O",e);let{breakOutRoom:t,type:r}=e;"rtmpStream"===r||this.emit("recordingEnded",{})};startProcessing=async({inputFiles:e=[],outputQualities:t=null,bucket:r=null,cloud:s=null,region:i=null}={})=>{In.debug("Processing of Files requested for:%o",e);const a=Math.round(1e7*Math.random()),n=await async function(e){if(Ba.info("The input files are:%o, length:%s",e,e.length),e.length>0){Ba.info("Files array length is:%s",e.length);for(const{type:t,url:r}of e){if(Ba.info("The file detais are type:%s, url:%s",t,r),!Fa.includes(t))return{success:!1,reason:`Type "${t}" is not allowed.`};if(!$a(r,t))return{success:!1,reason:`Extension mismatch for ${r}; expected .${t}`}}return{success:!0}}return{success:!1,reason:"There are no files for processing!"}}(e);if(n.success){if(t&&!Na(t))return In.error("Invalid outut qualities"),{success:!1,reason:`Invalid outputQualities: ${JSON.stringify(t)}. Allowed values are ${Array.from(ja).join(", ")}.`};this._processingStartedByMe={...this._processingStartedByMe,[a]:{}};for(const{type:t,url:r}of e)this._processingStartedByMe={...this._processingStartedByMe,[a]:{...this._processingStartedByMe[a],[r]:{type:t,url:r,status:"pending"}}};let n={id:"processVideos",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,inputFiles:e,outputQualities:t,bucket:r,cloud:s,region:i,requestId:a,type:"process"};return this._sendMessage(n),{success:!0}}return n};checkProcessingStatus=({requestId:e})=>(In.debug("Going to check processing status for request Id:%s",e),this._processingStartedByMe[e]?{success:!0,details:this._processingStartedByMe[e]}:{success:!0,details:this._processingStartedByMe});handleProcessingStart=e=>{const{processingStartTime:t,processingNo:r,requestId:s}=e;In.debug("handleProcessingStart()| received message is:%o",e),this.emit("processingStarted",{processingStartTime:t,requestId:s})};handleProcessingCompletion=e=>{const{totalProcessingTime:t,hlsfileKey:r,size:s,originalFile:i,lastFile:a,requestId:n}=e;if(In.debug("handleProcessingCompletion()| received message is:%o",e),In.debug("Before update, Total files to be processed are:%o",this._processingStartedByMe),this._processingStartedByMe[i]&&(this._processingStartedByMe={...this._processingStartedByMe,[n]:{...this._processingStartedByMe[n],[i]:{...this._processingStartedByMe[i],status:"completed",hlsfileKey:r,size:s,totalProcessingTime:t}}}),In.debug("After update, Total files to be processed are:%o",this._processingStartedByMe),this.emit("processingCompleted",e),a){In.debug("The last file processing has been completed! Remove all the files that has been completed with the same requesterId");let e={...this._processingStartedByMe};delete e[n],In.debug("After deleting the current requestId:%o",e),this._processingStartedByMe=e}};handleProcessingError=e=>{const{totalProcessingTime:t,hlsfileKey:r,size:s,originalFile:i,lastFile:a,requestId:n,error:o}=e;In.debug("handleProcessingCompletion()| received message is:%o",e),In.debug("Before update, Total files to be processed are:%o",this._processingStartedByMe),this._processingStartedByMe[i]&&(this._processingStartedByMe={...this._processingStartedByMe,[n]:{...this._processingStartedByMe[n],[i]:{...this._processingStartedByMe[i],status:"error",hlsfileKey:r,size:s,totalProcessingTime:t,error:o}}}),In.debug("After update, Total files to be processed are:%o",this._processingStartedByMe),this.emit("processingError",e)};async enableMic({deviceId:e=null,autoGainControl:t,noiseSuppression:r,echoCancellation:s,channelCount:i,sampleRate:a,forcePCMU:n,forcePCMA:o}={}){if(In.debug("enableMic()"),!this.data.inputParams.produce)return In.debug("Produce status is set to false!"),{success:!1,error:!0,code:"REID007",text:"Error while trying to start Mic/Audio. Produce flag need to set to true while joining room in order to enable Mic/Audio."};if("connected"!==this._roomStatus)return In.debug("Room status is not connected yet!"),{success:!1,error:!0,code:"REID008",text:`Error while trying to start Mic/Audio as room not in connected status. Current room status:!${this._roomStatus}`,possibleReasons:"Did you forget to call joinRoom before enabling Mic? OR if you have already initiated the joinRoom process, then Mic will be enabled automatically once room join process completes."};if(this._micProducer)return In.debug("Mic is already active!"),{success:!1,warning:!0,code:"RWID002",text:"Error while trying to start Mic/Audio. Mic/Audio is already active!"};if(!this._device.canProduce("audio"))return In.error("enableMic() | cannot produce audio"),{success:!1,error:!0,code:"REID009",text:"Error while trying to start Mic/Audio. Mic/Audio couldnot be activated due to limitations on this device. If you think this device has a functional Mic and the problem persists even after multiple retries, please contact technical support with the error code."};let c,d;n&&"boolean"==typeof n&&(this.data.inputParams.forcePCMU=n),o&&"boolean"==typeof o&&(this.data.inputParams.forcePCMA=o),t&&"boolean"==typeof t&&(this.data.inputParams.autoGainControl=t),s&&"boolean"==typeof s&&(this.data.inputParams.echoCancellation=s),r&&"boolean"==typeof r&&(this.data.inputParams.noiseSuppression=r),a&&Number.isInteger(a)&&a<64e3&&a>8e3&&(this.data.inputParams.sampleRate=a),i&&Number.isInteger(i)&&i>0&&i<3&&(this.data.inputParams.channelCount=i);try{if(this._externalVideo)this._micStream=await this._getExternalVideoStream(),c=this._micStream.getAudioTracks()[0].clone();else{if(e?(d=this._deviceList.audioDevices.find((t=>t.deviceId===e)),d||(In.warn("Selected audio input deviceId:%s not found",e),d=this._deviceList.audioDevices[0])):d=this._deviceList.audioDevices[0],this._mic.device=d,!d)return In.error("No mic device found! Can't start audio!"),{success:!1,reason:"No mic available for starting audio!"};e&&this.data.inputParams.audioDeviceId!==e&&(this.data.inputParams.audioDeviceId=e),In.debug("enableMic() | calling getUserMedia()");try{this._micStream=await navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:d.deviceId},echoCancellation:this.data.inputParams.echoCancellation,noiseSuppression:this.data.inputParams.noiseSuppression,autoGainControl:this.data.inputParams.autoGainControl,sampleRate:this.data.inputParams.sampleRate,channelCount:this.data.inputParams.channelCount}}),c=this._micStream.getAudioTracks()[0]}catch(Kn){throw new Error("Error while acquiring mic. Possible issue with audio constraint values",Kn)}}this._micProducer=await this._sendTransport.produce({track:c,codecOptions:this.data.inputParams.forcePCMU||this.data.inputParams.forcePCMA?void 0:{opusStereo:!1,opusDtx:!0,opusFec:!0,opusNack:!0},codec:this.data.inputParams.forcePCMU?this._device.rtpCapabilities.codecs.find((e=>"audio/pcmu"===e.mimeType.toLowerCase())):this.data.inputParams.forcePCMA?this._device.rtpCapabilities.codecs.find((e=>"audio/pcma"===e.mimeType.toLowerCase())):void 0,appData:{mediaTag:"cam-audio"}}),this._producers.set("audio",{id:this._micProducer.id,paused:this._micProducer.paused,track:this._micProducer.track,rtpParameters:this._micProducer.rtpParameters,codec:this._micProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("micStart",{peerId:this.data.inputParams.peerId,audioTrack:this._micProducer.track,type:"local"}),this._micProducer.on("transportclose",(()=>{this._micProducer=null})),this._micProducer.on("trackended",(()=>{this.disableMic().catch((()=>{}))}))}catch(p){In.error("enableMic() | failed:%o",p),this.emit("error",{code:"EID002",text:"Error enabling microphone!"}),c&&c.stop()}}async disableMic(){if(In.debug("disableMic()"),this._micStream&&this._micStream.getAudioTracks().forEach((e=>e.stop())),this._micProducer){this._micProducer.close(),this._producers.delete("audio");try{let e={id:"closeProducerSDK",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"audio",producerId:this._micProducer.id};this._sendMessage(e),this.emit("micEnd",{peerId:this.data.inputParams.peerId,audioTrack:null,type:"local"})}catch(e){this.emit("error",{code:"EID003",text:"Error disabling microphone!"})}this._micProducer=null}}async muteMic(){In.debug("muteMic()"),this._micProducer.pause();try{let e={id:"toggleMedia",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"audio",audioStatus:!1,producerId:this._micProducer.id};this._sendMessage(e),this.emit("peerMuted",{peerId:this.data.inputParams.peerId,type:"local"})}catch(e){In.error("muteMic() | failed: %o",e),this.emit("error",{code:"EID004",text:"Error muting local microphone!"})}}async unmuteMic(){In.debug("unmuteMic()"),this._micProducer.resume();try{let e={id:"toggleMedia",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"audio",audioStatus:!0,producerId:this._micProducer.id};this._sendMessage(e),this.emit("peerUnMuted",{peerId:this.data.inputParams.peerId,type:"local"})}catch(e){In.error("unmuteMic() | failed: %o",e),this.emit("error",{code:"EID005",text:"Error unmuting local microphone!"})}}async enableCam({deviceId:e=null,videoResolution:t,forceVp8:r,forceVp9:s,forceH264:i,h264Profile:a,forceFPS:n,enableWebcamLayers:o,numSimulcastStreams:c,videoBitRates:d}={}){if(In.debug("enableWebcam()"),!this.data.inputParams.produce)return In.debug("Produce status is set to false!"),{success:!1,error:!0,code:"REID004",text:"Error while trying to start Camera. Produce flag need to set to true while joining room in order to enable Camera."};if("connected"!==this._roomStatus)return In.debug("Room status is not connected yet!"),{success:!1,error:!0,code:"REID005",text:`Error while trying to start Camera as room not in connected status. Current room status:!${this._roomStatus}`,possibleReasons:"Did you forget to call joinRoom before enabling Camera? OR if you have already initiated the joinRoom process, then Camera will be enabled automatically once room join process completes."};if(this._webcamProducer)return In.debug("Camera is already active!"),{success:!1,warning:!0,code:"RWID003",text:"Error while trying to start Camera. Camera is already active!"};if(!this._device.canProduce("video"))return In.error("enableWebcam() | cannot produce video"),{success:!1,error:!0,code:"REID006",text:"Error while trying to start Camera. Camera couldnot be activated due to limitations on this device. If you think this device has a functional camera and the problem persists even after multiple retries, please contact technical support with the error code."};let p,l;["hd","vga","qvga"].includes(t)&&(this.data.inputParams.videoResolution=t,this._webcam.resolution=t),r&&"boolean"==typeof r&&(this.data.inputParams.forceVp8=r),s&&"boolean"==typeof s&&(this.data.inputParams.forceVp9=s),i&&"boolean"==typeof i&&(this.data.inputParams.forceH264=i),a&&["high","low"].includes(a.toLowerCase())&&(this.data.inputParams.h264Profile=a),n&&Number.isInteger(n)&&n<65&&n>5&&(this.data.inputParams.forceFPS=25),o&&"boolean"==typeof o&&(this.data.inputParams.enableWebcamLayers=o,this._enableWebcamLayers=o),c&&Number.isInteger(c)&&c<4&&c>0&&(this.data.inputParams.numSimulcastStreams=c,this._numSimulcastStreams=c),Array.isArray(d)&&d.length>=1&&d.length<=3&&d.every((e=>Number.isInteger(e)&&e>=75&&e<=800))?(In.debug("videoBitRates values are correct"),this.data.inputParams.videoBitRates=d):In.warn("videobitrates values should be an integer array with maximum 3 elements and minimum 1 element. The values in the array are '[700,250,75]'");try{if(this._externalVideo)l={label:"external video"},this._webCamStream=await this._getExternalVideoStream(),p=this._webCamStream.getVideoTracks()[0].clone();else{e?(l=this._deviceList.videoDevices.find((t=>t.deviceId===e)),l||(In.warn("Selected deviceId:%s not found",e),l=this._deviceList.videoDevices[0])):l=this._deviceList.videoDevices[0],this._webcam.device=l;const{resolution:t}=this._webcam;if(!l)return In.error("No wencam device found! Can't start video!"),{success:!1,reason:"No Webcam available for starting video!"};e&&this.data.inputParams.videoDeviceId!==e&&(this.data.inputParams.videoDeviceId=e),In.debug("enableWebcam() | calling getUserMedia()"),this._webCamStream=await navigator.mediaDevices.getUserMedia({video:{deviceId:{exact:l.deviceId},...xn[t],frameRate:{ideal:this.data.inputParams.forceFPS}}}),p=this._webCamStream.getVideoTracks()[0]}let t,r;const s={videoGoogleStartBitrate:1e3};if(In.debug("Current device codec options are:%O",this._device.rtpCapabilities.codecs),this._forceVP8){if(r=this._device.rtpCapabilities.codecs.find((e=>"video/vp8"===e.mimeType.toLowerCase())),!r)throw new Error("desired VP8 codec+configuration is not supported")}else if(this._forceH264){if("high"===this.data.inputParams.h264Profile?r=this._device.rtpCapabilities.codecs.find((e=>"video/h264"===e.mimeType.toLowerCase()&&"4d001f"===e.parameters["profile-level-id"])):"low"===this.data.inputParams.h264Profile&&(r=this._device.rtpCapabilities.codecs.find((e=>"video/h264"===e.mimeType.toLowerCase()&&"42e01f"===e.parameters["profile-level-id"]))),!r)throw new Error("desired H264 codec+configuration is not supported");In.debug("Selected h264 codec is:%O",r)}else if(this._forceVP9&&(r=this._device.rtpCapabilities.codecs.find((e=>"video/vp9"===e.mimeType.toLowerCase())),!r))throw new Error("desired VP9 codec+configuration is not supported");if(this._enableWebcamLayers){const e=this._device.rtpCapabilities.codecs.find((e=>"video"===e.kind));this._forceVP9&&r||"video/vp9"===e.mimeType.toLowerCase()?t=[{maxBitrate:5e6,scalabilityMode:this._webcamScalabilityMode||"L3T3_KEY"}]:(t=[{scaleResolutionDownBy:1,maxBitrate:1e3*this.data.inputParams.videoBitRates[0],scalabilityMode:this._webcamScalabilityMode||"L1T3"}],this._numSimulcastStreams>1&&t.unshift({scaleResolutionDownBy:2,maxBitrate:1e3*this.data.inputParams.videoBitRates[1],scalabilityMode:this._webcamScalabilityMode||"L1T3"}),this._numSimulcastStreams>2&&t.unshift({scaleResolutionDownBy:4,maxBitrate:1e3*this.data.inputParams.videoBitRates[2],scalabilityMode:this._webcamScalabilityMode||"L1T3"}))}this._webcamProducer=await this._sendTransport.produce({track:p,encodings:t,codecOptions:s,codec:r,appData:{mediaTag:"cam-video"}}),this._producers.set("video",{id:this._webcamProducer.id,deviceLabel:l.label,type:this._getWebcamType(l),paused:this._webcamProducer.paused,track:this._webcamProducer.track,rtpParameters:this._webcamProducer.rtpParameters,codec:this._webcamProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("videoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._webcamProducer.track,type:"local"}),this._webcamProducer.on("transportclose",(()=>{this._webcamProducer=null})),this._webcamProducer.on("trackended",(()=>{this.disableCam().catch((()=>{}))}))}catch(h){In.error("enableWebcam() | failed:%o",h),this.emit("error",{code:"EID011",text:"Enable Webcam failed!"}),p&&p.stop()}}async disableCam(){if(In.debug("disableWebcam()"),this._webcamProducer){this._webcamProducer.close(),this._producers.delete("video");try{let e={id:"closeProducerSDK",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"video",producerId:this._webcamProducer.id};this._sendMessage(e),this.emit("videoEnd",{peerId:this.data.inputParams.peerId,videoTrack:null})}catch(e){this.emit("error",{code:"EID012",text:"Error while closing server side producer!"})}this._webcamProducer=null}}async _updateWebcams(){In.debug("_updateWebcams()"),this._webcams=new Map,In.debug("_updateWebcams() | calling enumerateDevices()");const e=await navigator.mediaDevices.enumerateDevices();for(const i of e)"videoinput"===i.kind&&this._webcams.set(i.deviceId,i);const t=Array.from(this._webcams.values()),r=t.length,s=this._webcam.device?this._webcam.device.deviceId:void 0;In.debug("_updateWebcams() [webcams:%o]",t),0===r?this._webcam.device=null:this._webcams.has(s)||(this._webcam.device=t[0])}async _getExternalVideoStream(){if(this._externalVideoStream)return this._externalVideoStream;if(this._externalVideo.readyState<3&&await new Promise((e=>this._externalVideo.addEventListener("canplay",e))),this._externalVideo.captureStream)this._externalVideoStream=this._externalVideo.captureStream();else{if(!this._externalVideo.mozCaptureStream)throw new Error("video.captureStream() not supported");this._externalVideoStream=this._externalVideo.mozCaptureStream()}return this._externalVideoStream}_getWebcamType(e){return/(back|rear)/i.test(e.label)?(In.debug("_getWebcamType() | it seems to be a back camera"),"back"):(In.debug("_getWebcamType() | it seems to be a front camera"),"front")}async changeVideoInput({resolution:e,deviceId:t,fps:r}){if(this._webcamProducer){return await this._changeVideoInput({resolution:e,deviceId:t,fps:r})}return In.error("No webcam producer available!"),{success:!1,reason:"You are not sharing your camera yet. Camera Input can be changed to a new camera only when you are sharing an existing camera. "}}async _changeVideoInput({resolution:e,deviceId:t,fps:r}){In.info("_changeVideoInput() | Inside"),e&&["hd","vga","qvga"].includes(e)?this._webcam.resolution=e:In.warn("Invalid video resolution value "),r&&Number.isInteger(r)&&r<65&&r>5?this.data.inputParams.forceFPS=r:In.warn("forceFPS should be a number between 5 to 65, default value is 25 fps.");let s=this._deviceList.videoDevices.find((e=>t&&e.deviceId===t));if(!s)return In.error("The selected deviceId not found!"),{success:!1,reason:"Invalid deviceId!"};this._webcam.device=s;try{this._webCamStream.getVideoTracks().forEach((e=>e.stop())),this._webCamStream=null,In.debug("changeVideoInput() | calling getUserMedia()"),this._webCamStream=await navigator.mediaDevices.getUserMedia({video:{deviceId:{exact:s.deviceId},...xn[this._webcam.resolution],frameRate:{ideal:this.data.inputParams.forceFPS}}});const e=this._webCamStream.getVideoTracks()[0];In.debug("The new video track is:%O",e),await this._webcamProducer.replaceTrack({track:e});let t=this._producers.get("video");return t.deviceLabel=s.label,t.type=this._getWebcamType(s),t.track=this._webcamProducer.track,In.debug("Updated producer values are:%O",t),this._producers.set("video",t),this.emit("videoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._webcamProducer.track,type:"local"}),{success:!0}}catch(i){return In.error("Error while changing input:%O",i),{success:!1,reason:"Couldn't change video input",error:i}}}async changeAudioInput({autoGainControl:e,echoCancellation:t,noiseSuppression:r,sampleRate:s,channelCount:i,deviceId:a}){if(this._micProducer){return await this._changeAudioInput({autoGainControl:e,echoCancellation:t,noiseSuppression:r,sampleRate:s,channelCount:i,deviceId:a})}return{success:!1,reason:"You are not sharing your mic yet. Mic Input can be changed to a new mic only when you are sharing an existing mic. "}}async _changeAudioInput({autoGainControl:e,echoCancellation:t,noiseSuppression:r,sampleRate:s,channelCount:i,deviceId:a}){e&&"boolean"==typeof e&&(this.data.inputParams.autoGainControl=e),t&&"boolean"==typeof t&&(this.data.inputParams.echoCancellation=Boolean(t)),r&&"boolean"==typeof r&&(this.data.inputParams.noiseSuppression=Boolean(r)),s&&Number.isInteger(s)&&s<64e3&&s>8e3&&(this.data.inputParams.sampleRate=s),i&&Number.isInteger(i)&&i>0&&i<3&&(this.data.inputParams.channelCount=i);let n=this._deviceList.audioDevices.find((e=>a&&e.deviceId===a));if(!n)return{success:!1,reason:"Invalid deviceId!"};this._mic.device=n,this._micStream&&this._micStream.getAudioTracks().forEach((e=>e.stop())),this._micStream=null;try{this._micStream=await navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:n.deviceId},echoCancellation:this.data.inputParams.echoCancellation,noiseSuppression:this.data.inputParams.noiseSuppression,autoGainControl:this.data.inputParams.autoGainControl,sampleRate:this.data.inputParams.sampleRate,channelCount:this.data.inputParams.channelCount}});const e=this._micStream.getAudioTracks()[0];this._micProducer.replaceTrack({track:e});let t=this._producers.get("audio");return t.deviceLabel=n.label,t.track=this._micProducer.track,In.debug("Updated producer values are:%O",t),this._producers.set("audio",t),this.emit("micStart",{peerId:this.data.inputParams.peerId,audioTrack:this._micProducer.track,type:"local"}),{success:!0}}catch(Kn){return In.error("Error while changing input:%O",Kn),{success:!1,reason:"Couldn't change audio input",err:Kn}}}async enableShare({shareAudio:e=!1,enableSharingLayers:t=!0,shareBitRates:r=[2500,1250,500]}={}){if(In.debug("enableShare()"),!this.data.inputParams.produce)return In.debug("Produce status is set to false!"),{success:!1,error:!0,code:"REID003",text:"Error while trying to start screen share. Produce flag need to set to true while joining room in order to enable screen share."};if("connected"!==this._roomStatus)return In.debug("Room status is not connected yet!"),{success:!1,error:!0,code:"REID001",text:`Error while trying to start screen share as room not in connected status. Current room status:!${this._roomStatus}`,possibleReasons:"Did you forget to call joinRoom before enabling screen share? OR if you have already initiated the joinRoom process, then try enabling screen share after some seconds."};if(this._shareProducer)return In.debug("Screen share is already active!"),{success:!1,warning:!0,code:"RWID001",text:"Error while trying to start screen share. Screen share is already active!"};if(!this._device.canProduce("video"))return In.error("enableShare() | cannot produce video"),{success:!1,error:!0,code:"REID002",text:"Error while trying to start screen share. Screen share couldnot be activated due to limitations on this device. If you think this device is capable of screen share and the problem persists even after multiple retries, please contact technical support with the error code."};let s,i;this._enableSharingLayers="boolean"!=typeof t?Boolean(t):t,Array.isArray(r)&&r.length>=1&&r.length<=3&&r.every((e=>Number.isInteger(e)&&e>=500&&e<=2500))?this.data.inputParams.shareBitRates=r:this.data.inputParams.shareBitRates=[2500,1250,500];try{In.debug("enableShare() | calling getDisplayMedia()");const t=await navigator.mediaDevices.getDisplayMedia({audio:!!e,video:{displaySurface:"monitor",logicalSurface:!0,cursor:!0,width:{max:1920},height:{max:1080},frameRate:{max:30}}});if(!t)return In.error("Unable to capture screen."),void this.emit("error",{code:"EID013",text:"Error while trying to start screen share. Not able to capture screen!"});let r,a;i=t.getAudioTracks()[0],i&&(this._shareAudioProducer=await this._sendTransport.produce({track:i,codecOptions:this.data.inputParams.forcePCMU?void 0:{opusStereo:!1,opusDtx:!0,opusFec:!0,opusNack:!0},codec:this.data.inputParams.forcePCMU?this._device.rtpCapabilities.codecs.find((e=>"audio/pcmu"===e.mimeType.toLowerCase())):void 0,appData:{mediaTag:"screen-audio"}}),this._producers.set("ssAudio",{id:this._shareAudioProducer.id,type:"shareAudio",paused:this._shareAudioProducer.paused,track:this._shareAudioProducer.track,rtpParameters:this._shareAudioProducer.rtpParameters,codec:this._shareAudioProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("ssAudioStart",{peerId:this.data.inputParams.peerId,audioTrack:this._shareAudioProducer.track,type:"local"})),s=t.getVideoTracks()[0];const n={videoGoogleStartBitrate:1e3};if(this._forceVP8){if(a=this._device.rtpCapabilities.codecs.find((e=>"video/vp8"===e.mimeType.toLowerCase())),!a)throw new Error("desired VP8 codec+configuration is not supported")}else if(this._forceH264){if("high"===this.data.inputParams.h264Profile?a=this._device.rtpCapabilities.codecs.find((e=>"video/h264"===e.mimeType.toLowerCase()&&"4d001f"===e.parameters["profile-level-id"])):"low"===this.data.inputParams.h264Profile&&(a=this._device.rtpCapabilities.codecs.find((e=>"video/h264"===e.mimeType.toLowerCase()&&"42e01f"===e.parameters["profile-level-id"]))),!a)throw new Error("desired H264 codec+configuration is not supported");In.debug("Selected h264 codec is:%O",a)}else if(this._forceVP9&&(a=this._device.rtpCapabilities.codecs.find((e=>"video/vp9"===e.mimeType.toLowerCase())),!a))throw new Error("desired VP9 codec+configuration is not supported");if(this._enableSharingLayers){const e=this._device.rtpCapabilities.codecs.find((e=>"video"===e.kind));this._forceVP9&&a||"video/vp9"===e.mimeType.toLowerCase()?r=[{maxBitrate:1e3*this.data.inputParams.shareBitRates[0],scalabilityMode:this._sharingScalabilityMode||"L3T3",dtx:!0}]:(r=[{scaleResolutionDownBy:1,maxBitrate:1e3*this.data.inputParams.shareBitRates[0],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}],this._numSimulcastStreams>1&&r.unshift({scaleResolutionDownBy:2,maxBitrate:1e3*this.data.inputParams.shareBitRates[1],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}),this._numSimulcastStreams>2&&r.unshift({scaleResolutionDownBy:4,maxBitrate:1e3*this.data.inputParams.shareBitRates[2],scalabilityMode:this._sharingScalabilityMode||"L1T3",dtx:!0}))}this._shareProducer=await this._sendTransport.produce({track:s,encodings:r,codecOptions:n,codec:a,appData:{mediaTag:"screen-video"}}),this._producers.set("ssVideo",{id:this._shareProducer.id,type:"shareVideo",paused:this._shareProducer.paused,track:this._shareProducer.track,rtpParameters:this._shareProducer.rtpParameters,codec:this._shareProducer.rtpParameters.codecs[0].mimeType.split("/")[1]}),this.emit("ssVideoStart",{peerId:this.data.inputParams.peerId,videoTrack:this._shareProducer.track,type:"local"}),this._shareProducer.on("transportclose",(()=>{this._shareProducer=null})),this._shareProducer.on("trackended",(()=>{this.disableShare().catch((()=>{}))}))}catch(a){In.error("enableShare() | failed:%o",a),"NotAllowedError"!==a.name&&this.emit("error",{code:"EID014",text:`Error while trying to start screen share. Error is: ${a}!`}),s&&s.stop()}}async disableShare(){if(In.debug("disableShare()"),!this._shareProducer)return In.warn("Screen share doesn't seem to be on!"),void this.emit("error",{code:"EID017",text:"Error while trying to stop screen share. Is the screen share on!"});if(this._shareProducer.close(),this._shareAudioProducer){this._shareAudioProducer.close();try{let e={id:"closeProducerSDK",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"audio",producerId:this._shareAudioProducer.id};this._sendMessage(e),this.emit("ssAudioStop",{peerId:this.data.inputParams.peerId,videoTrack:null,type:"local"})}catch(e){this.emit("error",{code:"EID015",text:`Error while trying to stop screen share audio. Error is: ${e}!`})}}try{let e={id:"closeProducerSDK",peerId:this.data.inputParams.peerId,roomName:this.data.inputParams.roomId,type:"video",producerId:this._shareProducer.id};this._sendMessage(e),this.emit("ssVideoStop",{peerId:this.data.inputParams.peerId,videoTrack:null,type:"local"})}catch(e){this.emit("error",{code:"EID016",text:`Error while trying to stop screen share video. Error is: ${e}!`})}this._shareAudioProducer=null,this._shareProducer=null}}const An="cp2p-client";class jn{constructor(e){e?(this._debug=Ft(`${An}:${e}`),this._info=Ft(`${An}:INFO:${e}`),this._warn=Ft(`${An}:WARN:${e}`),this._error=Ft(`${An}:ERROR:${e}`)):(this._debug=Ft(An),this._info=Ft(`${An}:INFO`),this._warn=Ft(`${An}:WARN`),this._error=Ft(`${An}:ERROR`)),this._debug.log=void 0,this._info.log=void 0,this._warn.log=void 0,this._error.log=void 0}get debug(){return this._debug}get info(){return this._info}get warn(){return this._warn}get error(){return this._error}}const Nn={audio:{deviceId:{exact:void 0}},video:!1},Bn={video:{deviceId:{exact:void 0},width:{min:320,ideal:640,max:1280},height:{min:240,ideal:480,max:720},frameRate:{min:15,max:30}}},Fn={audio:!0,video:{width:{min:320,ideal:1280,max:1280},height:{min:240,ideal:720,max:720},aspectRatio:1.777777778,frameRate:{min:15,max:30}}},$n=new jn("socket");class Un extends Wt.EventEmitter{constructor({url:e,roomId:t,peerId:r,peerName:s,role:i}){super(),$n.debug("constructor():%o ",{url:e,roomId:t,peerId:r,peerName:s,role:i}),this._closed=!1,this._params={url:e,roomId:t,peerId:r,peerName:s,role:i},this._socket=null,this._connectionStatus=null,this._createSocket()}get closed(){return this._closed}get connectionStatus(){return this._connectionStatus}close(){if(!this._closed){$n.debug("close()"),this._closed=!0,this.emit("close");try{this._socket.disconnect()}catch(e){$n.error("close() | error closing the Socket:%o",e)}}}async send(e){if(this._closed)throw new Error("transport closed");try{this._socket.send(JSON.stringify(e))}catch(t){throw $n.warn("send() failed:%o",t),t}}async request({type:e,message:t}){return new Promise((r=>{if(this._closed)throw new Error("transport closed");try{this._socket.emit(e,JSON.stringify(t),(e=>{r(e)}))}catch(s){throw $n.warn("emit() failed:%o",s),s}}))}async _createSocket(){let e=this;const t=io(this._params.url,{query:{roomId:this._params.roomId,peerId:this._params.peerId,peerName:this._params.peerName,role:this._params.role}});t.on("connect",(()=>{$n.debug("Socket connected!!"),e._connectionStatus=!0,e.emit("connected")})),t.on("disconnect",(()=>{$n.debug("Socket disconnected!!"),e._connectionStatus=!1,e.emit("disconnected")})),t.on("reconnect",(()=>{$n.debug("Socket reconnected after disconnect!!"),t.emit("reconnected")})),t.on("message",(t=>{const r=JSON.parse(t);$n.debug("New mesage received with id:%s",r.type),e.emit("message",r)})),this._socket=t}}
|
|
18
9
|
/*!
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
t.exports=function(e){return null!=e&&(i(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&i(e.slice(0,0))}(e)||!!e._isBuffer)}},{}],176:[function(e,t,r){var i={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==i.call(e)}},{}],177:[function(e,t,r){var i=e("jws");t.exports=function(e,t){t=t||{};var r=i.decode(e,t);if(!r)return null;var n=r.payload;if("string"==typeof n)try{var a=JSON.parse(n);null!==a&&"object"==typeof a&&(n=a)}catch(e){}return!0===t.complete?{header:r.header,payload:n,signature:r.signature}:n}},{jws:188}],178:[function(e,t,r){t.exports={decode:e("./decode"),verify:e("./verify"),sign:e("./sign"),JsonWebTokenError:e("./lib/JsonWebTokenError"),NotBeforeError:e("./lib/NotBeforeError"),TokenExpiredError:e("./lib/TokenExpiredError")}},{"./decode":177,"./lib/JsonWebTokenError":179,"./lib/NotBeforeError":180,"./lib/TokenExpiredError":181,"./sign":185,"./verify":186}],179:[function(e,t,r){var i=function(e,t){Error.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=e,t&&(this.inner=t)};(i.prototype=Object.create(Error.prototype)).constructor=i,t.exports=i},{}],180:[function(e,t,r){var i=e("./JsonWebTokenError"),n=function(e,t){i.call(this,e),this.name="NotBeforeError",this.date=t};(n.prototype=Object.create(i.prototype)).constructor=n,t.exports=n},{"./JsonWebTokenError":179}],181:[function(e,t,r){var i=e("./JsonWebTokenError"),n=function(e,t){i.call(this,e),this.name="TokenExpiredError",this.expiredAt=t};(n.prototype=Object.create(i.prototype)).constructor=n,t.exports=n},{"./JsonWebTokenError":179}],182:[function(e,t,r){(function(r){(function(){var i=e("semver");t.exports=i.satisfies(r.version,"^6.12.0 || >=8.0.0")}).call(this)}).call(this,e("_process"))},{_process:257,semver:184}],183:[function(e,t,r){var i=e("ms");t.exports=function(e,t){var r=t||Math.floor(Date.now()/1e3);if("string"==typeof e){var n=i(e);if(void 0===n)return;return Math.floor(r+n/1e3)}return"number"==typeof e?r+e:void 0}},{ms:241}],184:[function(e,t,r){(function(e){(function(){var i;r=t.exports=Q,i="object"==typeof e&&e.env&&e.env.NODE_DEBUG&&/\bsemver\b/i.test(e.env.NODE_DEBUG)?function(){var e=Array.prototype.slice.call(arguments,0);e.unshift("SEMVER"),console.log.apply(console,e)}:function(){},r.SEMVER_SPEC_VERSION="2.0.0";var n=256,a=Number.MAX_SAFE_INTEGER||9007199254740991,s=n-6,o=r.re=[],c=r.safeRe=[],d=r.src=[],u=0,l="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",n],[l,s]];function f(e){for(var t=0;t<h.length;t++){var r=h[t][0],i=h[t][1];e=e.split(r+"*").join(r+"{0,"+i+"}").split(r+"+").join(r+"{1,"+i+"}")}return e}var p=u++;d[p]="0|[1-9]\\d*";var m=u++;d[m]="\\d+";var b=u++;d[b]="\\d*[a-zA-Z-]"+l+"*";var g=u++;d[g]="("+d[p]+")\\.("+d[p]+")\\.("+d[p]+")";var v=u++;d[v]="("+d[m]+")\\.("+d[m]+")\\.("+d[m]+")";var y=u++;d[y]="(?:"+d[p]+"|"+d[b]+")";var _=u++;d[_]="(?:"+d[m]+"|"+d[b]+")";var w=u++;d[w]="(?:-("+d[y]+"(?:\\."+d[y]+")*))";var S=u++;d[S]="(?:-?("+d[_]+"(?:\\."+d[_]+")*))";var k=u++;d[k]=l+"+";var R=u++;d[R]="(?:\\+("+d[k]+"(?:\\."+d[k]+")*))";var P=u++,M="v?"+d[g]+d[w]+"?"+d[R]+"?";d[P]="^"+M+"$";var E="[v=\\s]*"+d[v]+d[S]+"?"+d[R]+"?",x=u++;d[x]="^"+E+"$";var T=u++;d[T]="((?:<|>)?=?)";var C=u++;d[C]=d[m]+"|x|X|\\*";var I=u++;d[I]=d[p]+"|x|X|\\*";var D=u++;d[D]="[v=\\s]*("+d[I]+")(?:\\.("+d[I]+")(?:\\.("+d[I]+")(?:"+d[w]+")?"+d[R]+"?)?)?";var O=u++;d[O]="[v=\\s]*("+d[C]+")(?:\\.("+d[C]+")(?:\\.("+d[C]+")(?:"+d[S]+")?"+d[R]+"?)?)?";var A=u++;d[A]="^"+d[T]+"\\s*"+d[D]+"$";var L=u++;d[L]="^"+d[T]+"\\s*"+d[O]+"$";var j=u++;d[j]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var B=u++;d[B]="(?:~>?)";var N=u++;d[N]="(\\s*)"+d[B]+"\\s+",o[N]=new RegExp(d[N],"g"),c[N]=new RegExp(f(d[N]),"g");var F=u++;d[F]="^"+d[B]+d[D]+"$";var U=u++;d[U]="^"+d[B]+d[O]+"$";var q=u++;d[q]="(?:\\^)";var z=u++;d[z]="(\\s*)"+d[q]+"\\s+",o[z]=new RegExp(d[z],"g"),c[z]=new RegExp(f(d[z]),"g");var V=u++;d[V]="^"+d[q]+d[D]+"$";var G=u++;d[G]="^"+d[q]+d[O]+"$";var W=u++;d[W]="^"+d[T]+"\\s*("+E+")$|^$";var H=u++;d[H]="^"+d[T]+"\\s*("+M+")$|^$";var K=u++;d[K]="(\\s*)"+d[T]+"\\s*("+E+"|"+d[D]+")",o[K]=new RegExp(d[K],"g"),c[K]=new RegExp(f(d[K]),"g");var $=u++;d[$]="^\\s*("+d[D]+")\\s+-\\s+("+d[D]+")\\s*$";var J=u++;d[J]="^\\s*("+d[O]+")\\s+-\\s+("+d[O]+")\\s*$";var Y=u++;d[Y]="(<|>)?=?\\s*\\*";for(var X=0;X<35;X++)i(X,d[X]),o[X]||(o[X]=new RegExp(d[X]),c[X]=new RegExp(f(d[X])));function Z(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof Q)return e;if("string"!=typeof e)return null;if(e.length>n)return null;if(!(t.loose?c[x]:c[P]).test(e))return null;try{return new Q(e,t)}catch(e){return null}}function Q(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof Q){if(e.loose===t.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>n)throw new TypeError("version is longer than "+n+" characters");if(!(this instanceof Q))return new Q(e,t);i("SemVer",e,t),this.options=t,this.loose=!!t.loose;var r=e.trim().match(t.loose?c[x]:c[P]);if(!r)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>a||this.major<0)throw new TypeError("Invalid major version");if(this.minor>a||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>a||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map((function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t<a)return t}return e})):this.prerelease=[],this.build=r[5]?r[5].split("."):[],this.format()}r.parse=Z,r.valid=function(e,t){var r=Z(e,t);return r?r.version:null},r.clean=function(e,t){var r=Z(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null},r.SemVer=Q,Q.prototype.format=function(){return this.version=this.major+"."+this.minor+"."+this.patch,this.prerelease.length&&(this.version+="-"+this.prerelease.join(".")),this.version},Q.prototype.toString=function(){return this.version},Q.prototype.compare=function(e){return i("SemVer.compare",this.version,this.options,e),e instanceof Q||(e=new Q(e,this.options)),this.compareMain(e)||this.comparePre(e)},Q.prototype.compareMain=function(e){return e instanceof Q||(e=new Q(e,this.options)),te(this.major,e.major)||te(this.minor,e.minor)||te(this.patch,e.patch)},Q.prototype.comparePre=function(e){if(e instanceof Q||(e=new Q(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;var t=0;do{var r=this.prerelease[t],n=e.prerelease[t];if(i("prerelease compare",t,r,n),void 0===r&&void 0===n)return 0;if(void 0===n)return 1;if(void 0===r)return-1;if(r!==n)return te(r,n)}while(++t)},Q.prototype.inc=function(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t),this.inc("pre",t);break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else{for(var r=this.prerelease.length;--r>=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},r.inc=function(e,t,r,i){"string"==typeof r&&(i=r,r=void 0);try{return new Q(e,r).inc(t,i).version}catch(e){return null}},r.diff=function(e,t){if(ae(e,t))return null;var r=Z(e),i=Z(t),n="";if(r.prerelease.length||i.prerelease.length){n="pre";var a="prerelease"}for(var s in r)if(("major"===s||"minor"===s||"patch"===s)&&r[s]!==i[s])return n+s;return a},r.compareIdentifiers=te;var ee=/^[0-9]+$/;function te(e,t){var r=ee.test(e),i=ee.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1}function re(e,t,r){return new Q(e,r).compare(new Q(t,r))}function ie(e,t,r){return re(e,t,r)>0}function ne(e,t,r){return re(e,t,r)<0}function ae(e,t,r){return 0===re(e,t,r)}function se(e,t,r){return 0!==re(e,t,r)}function oe(e,t,r){return re(e,t,r)>=0}function ce(e,t,r){return re(e,t,r)<=0}function de(e,t,r,i){switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e===r;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e!==r;case"":case"=":case"==":return ae(e,r,i);case"!=":return se(e,r,i);case">":return ie(e,r,i);case">=":return oe(e,r,i);case"<":return ne(e,r,i);case"<=":return ce(e,r,i);default:throw new TypeError("Invalid operator: "+t)}}function ue(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof ue){if(e.loose===!!t.loose)return e;e=e.value}if(!(this instanceof ue))return new ue(e,t);e=e.trim().split(/\s+/).join(" "),i("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===le?this.value="":this.value=this.operator+this.semver.version,i("comp",this)}r.rcompareIdentifiers=function(e,t){return te(t,e)},r.major=function(e,t){return new Q(e,t).major},r.minor=function(e,t){return new Q(e,t).minor},r.patch=function(e,t){return new Q(e,t).patch},r.compare=re,r.compareLoose=function(e,t){return re(e,t,!0)},r.rcompare=function(e,t,r){return re(t,e,r)},r.sort=function(e,t){return e.sort((function(e,i){return r.compare(e,i,t)}))},r.rsort=function(e,t){return e.sort((function(e,i){return r.rcompare(e,i,t)}))},r.gt=ie,r.lt=ne,r.eq=ae,r.neq=se,r.gte=oe,r.lte=ce,r.cmp=de,r.Comparator=ue;var le={};function he(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof he)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new he(e.raw,t);if(e instanceof ue)return new he(e.value,t);if(!(this instanceof he))return new he(e,t);if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map((function(e){return this.parseRange(e.trim())}),this).filter((function(e){return e.length})),!this.set.length)throw new TypeError("Invalid SemVer Range: "+this.raw);this.format()}function fe(e){return!e||"x"===e.toLowerCase()||"*"===e}function pe(e,t,r,i,n,a,s,o,c,d,u,l,h){return((t=fe(r)?"":fe(i)?">="+r+".0.0":fe(n)?">="+r+"."+i+".0":">="+t)+" "+(o=fe(c)?"":fe(d)?"<"+(+c+1)+".0.0":fe(u)?"<"+c+"."+(+d+1)+".0":l?"<="+c+"."+d+"."+u+"-"+l:"<="+o)).trim()}function me(e,t,r){for(var n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(n=0;n<e.length;n++)if(i(e[n].semver),e[n].semver!==le&&e[n].semver.prerelease.length>0){var a=e[n].semver;if(a.major===t.major&&a.minor===t.minor&&a.patch===t.patch)return!0}return!1}return!0}function be(e,t,r){try{t=new he(t,r)}catch(e){return!1}return t.test(e)}function ge(e,t,r,i){var n,a,s,o,c;switch(e=new Q(e,i),t=new he(t,i),r){case">":n=ie,a=ce,s=ne,o=">",c=">=";break;case"<":n=ne,a=oe,s=ie,o="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(be(e,t,i))return!1;for(var d=0;d<t.set.length;++d){var u=t.set[d],l=null,h=null;if(u.forEach((function(e){e.semver===le&&(e=new ue(">=0.0.0")),l=l||e,h=h||e,n(e.semver,l.semver,i)?l=e:s(e.semver,h.semver,i)&&(h=e)})),l.operator===o||l.operator===c)return!1;if((!h.operator||h.operator===o)&&a(e,h.semver))return!1;if(h.operator===c&&s(e,h.semver))return!1}return!0}ue.prototype.parse=function(e){var t=this.options.loose?c[W]:c[H],r=e.match(t);if(!r)throw new TypeError("Invalid comparator: "+e);this.operator=r[1],"="===this.operator&&(this.operator=""),r[2]?this.semver=new Q(r[2],this.options.loose):this.semver=le},ue.prototype.toString=function(){return this.value},ue.prototype.test=function(e){return i("Comparator.test",e,this.options.loose),this.semver===le||("string"==typeof e&&(e=new Q(e,this.options)),de(e,this.operator,this.semver,this.options))},ue.prototype.intersects=function(e,t){if(!(e instanceof ue))throw new TypeError("a Comparator is required");var r;if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),""===this.operator)return r=new he(e.value,t),be(this.value,r,t);if(""===e.operator)return r=new he(this.value,t),be(e.semver,r,t);var i=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),n=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),a=this.semver.version===e.semver.version,s=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),o=de(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),c=de(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return i||n||a&&s||o||c},r.Range=he,he.prototype.format=function(){return this.range=this.set.map((function(e){return e.join(" ").trim()})).join("||").trim(),this.range},he.prototype.toString=function(){return this.range},he.prototype.parseRange=function(e){var t=this.options.loose,r=t?c[J]:c[$];e=e.replace(r,pe),i("hyphen replace",e),e=e.replace(c[K],"$1$2$3"),i("comparator trim",e,c[K]),e=(e=e.replace(c[N],"$1~")).replace(c[z],"$1^");var n=t?c[W]:c[H],a=e.split(" ").map((function(e){return function(e,t){return i("comp",e,t),e=function(e,t){return e.trim().split(/\s+/).map((function(e){return function(e,t){i("caret",e,t);var r=t.loose?c[G]:c[V];return e.replace(r,(function(t,r,n,a,s){var o;return i("caret",e,t,r,n,a,s),fe(r)?o="":fe(n)?o=">="+r+".0.0 <"+(+r+1)+".0.0":fe(a)?o="0"===r?">="+r+"."+n+".0 <"+r+"."+(+n+1)+".0":">="+r+"."+n+".0 <"+(+r+1)+".0.0":s?(i("replaceCaret pr",s),o="0"===r?"0"===n?">="+r+"."+n+"."+a+"-"+s+" <"+r+"."+n+"."+(+a+1):">="+r+"."+n+"."+a+"-"+s+" <"+r+"."+(+n+1)+".0":">="+r+"."+n+"."+a+"-"+s+" <"+(+r+1)+".0.0"):(i("no pr"),o="0"===r?"0"===n?">="+r+"."+n+"."+a+" <"+r+"."+n+"."+(+a+1):">="+r+"."+n+"."+a+" <"+r+"."+(+n+1)+".0":">="+r+"."+n+"."+a+" <"+(+r+1)+".0.0"),i("caret return",o),o}))}(e,t)})).join(" ")}(e,t),i("caret",e),e=function(e,t){return e.trim().split(/\s+/).map((function(e){return function(e,t){var r=t.loose?c[U]:c[F];return e.replace(r,(function(t,r,n,a,s){var o;return i("tilde",e,t,r,n,a,s),fe(r)?o="":fe(n)?o=">="+r+".0.0 <"+(+r+1)+".0.0":fe(a)?o=">="+r+"."+n+".0 <"+r+"."+(+n+1)+".0":s?(i("replaceTilde pr",s),o=">="+r+"."+n+"."+a+"-"+s+" <"+r+"."+(+n+1)+".0"):o=">="+r+"."+n+"."+a+" <"+r+"."+(+n+1)+".0",i("tilde return",o),o}))}(e,t)})).join(" ")}(e,t),i("tildes",e),e=function(e,t){return i("replaceXRanges",e,t),e.split(/\s+/).map((function(e){return function(e,t){e=e.trim();var r=t.loose?c[L]:c[A];return e.replace(r,(function(t,r,n,a,s,o){i("xRange",e,t,r,n,a,s,o);var c=fe(n),d=c||fe(a),u=d||fe(s);return"="===r&&u&&(r=""),c?t=">"===r||"<"===r?"<0.0.0":"*":r&&u?(d&&(a=0),s=0,">"===r?(r=">=",d?(n=+n+1,a=0,s=0):(a=+a+1,s=0)):"<="===r&&(r="<",d?n=+n+1:a=+a+1),t=r+n+"."+a+"."+s):d?t=">="+n+".0.0 <"+(+n+1)+".0.0":u&&(t=">="+n+"."+a+".0 <"+n+"."+(+a+1)+".0"),i("xRange return",t),t}))}(e,t)})).join(" ")}(e,t),i("xrange",e),e=function(e,t){return i("replaceStars",e,t),e.trim().replace(c[Y],"")}(e,t),i("stars",e),e}(e,this.options)}),this).join(" ").split(/\s+/);return this.options.loose&&(a=a.filter((function(e){return!!e.match(n)}))),a=a.map((function(e){return new ue(e,this.options)}),this)},he.prototype.intersects=function(e,t){if(!(e instanceof he))throw new TypeError("a Range is required");return this.set.some((function(r){return r.every((function(r){return e.set.some((function(e){return e.every((function(e){return r.intersects(e,t)}))}))}))}))},r.toComparators=function(e,t){return new he(e,t).set.map((function(e){return e.map((function(e){return e.value})).join(" ").trim().split(" ")}))},he.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new Q(e,this.options));for(var t=0;t<this.set.length;t++)if(me(this.set[t],e,this.options))return!0;return!1},r.satisfies=be,r.maxSatisfying=function(e,t,r){var i=null,n=null;try{var a=new he(t,r)}catch(e){return null}return e.forEach((function(e){a.test(e)&&(i&&-1!==n.compare(e)||(n=new Q(i=e,r)))})),i},r.minSatisfying=function(e,t,r){var i=null,n=null;try{var a=new he(t,r)}catch(e){return null}return e.forEach((function(e){a.test(e)&&(i&&1!==n.compare(e)||(n=new Q(i=e,r)))})),i},r.minVersion=function(e,t){e=new he(e,t);var r=new Q("0.0.0");if(e.test(r))return r;if(r=new Q("0.0.0-0"),e.test(r))return r;r=null;for(var i=0;i<e.set.length;++i){e.set[i].forEach((function(e){var t=new Q(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":r&&!ie(r,t)||(r=t);break;case"<":case"<=":break;default:throw new Error("Unexpected operation: "+e.operator)}}))}if(r&&e.test(r))return r;return null},r.validRange=function(e,t){try{return new he(e,t).range||"*"}catch(e){return null}},r.ltr=function(e,t,r){return ge(e,t,"<",r)},r.gtr=function(e,t,r){return ge(e,t,">",r)},r.outside=ge,r.prerelease=function(e,t){var r=Z(e,t);return r&&r.prerelease.length?r.prerelease:null},r.intersects=function(e,t,r){return e=new he(e,r),t=new he(t,r),e.intersects(t)},r.coerce=function(e){if(e instanceof Q)return e;if("string"!=typeof e)return null;var t=e.match(c[j]);if(null==t)return null;return Z(t[1]+"."+(t[2]||"0")+"."+(t[3]||"0"))}}).call(this)}).call(this,e("_process"))},{_process:257}],185:[function(e,t,r){(function(r){(function(){var i=e("./lib/timespan"),n=e("./lib/psSupported"),a=e("jws"),s=e("lodash.includes"),o=e("lodash.isboolean"),c=e("lodash.isinteger"),d=e("lodash.isnumber"),u=e("lodash.isplainobject"),l=e("lodash.isstring"),h=e("lodash.once"),f=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];n&&f.splice(3,0,"PS256","PS384","PS512");var p={expiresIn:{isValid:function(e){return c(e)||l(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return c(e)||l(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return l(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:s.bind(null,f),message:'"algorithm" must be a valid string enum value'},header:{isValid:u,message:'"header" must be an object'},encoding:{isValid:l,message:'"encoding" must be a string'},issuer:{isValid:l,message:'"issuer" must be a string'},subject:{isValid:l,message:'"subject" must be a string'},jwtid:{isValid:l,message:'"jwtid" must be a string'},noTimestamp:{isValid:o,message:'"noTimestamp" must be a boolean'},keyid:{isValid:l,message:'"keyid" must be a string'},mutatePayload:{isValid:o,message:'"mutatePayload" must be a boolean'}},m={iat:{isValid:d,message:'"iat" should be a number of seconds'},exp:{isValid:d,message:'"exp" should be a number of seconds'},nbf:{isValid:d,message:'"nbf" should be a number of seconds'}};function b(e,t,r,i){if(!u(r))throw new Error('Expected "'+i+'" to be a plain object.');Object.keys(r).forEach((function(n){var a=e[n];if(a){if(!a.isValid(r[n]))throw new Error(a.message)}else if(!t)throw new Error('"'+n+'" is not allowed in "'+i+'"')}))}var g={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},v=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];t.exports=function(e,t,n,s){"function"==typeof n?(s=n,n={}):n=n||{};var o="object"==typeof e&&!r.isBuffer(e),c=Object.assign({alg:n.algorithm||"HS256",typ:o?"JWT":void 0,kid:n.keyid},n.header);function d(e){if(s)return s(e);throw e}if(!t&&"none"!==n.algorithm)return d(new Error("secretOrPrivateKey must have a value"));if(void 0===e)return d(new Error("payload is required"));if(o){try{!function(e){b(m,!0,e,"payload")}(e)}catch(e){return d(e)}n.mutatePayload||(e=Object.assign({},e))}else{var u=v.filter((function(e){return void 0!==n[e]}));if(u.length>0)return d(new Error("invalid "+u.join(",")+" option for "+typeof e+" payload"))}if(void 0!==e.exp&&void 0!==n.expiresIn)return d(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==e.nbf&&void 0!==n.notBefore)return d(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){b(p,!1,e,"options")}(n)}catch(e){return d(e)}var l=e.iat||Math.floor(Date.now()/1e3);if(n.noTimestamp?delete e.iat:o&&(e.iat=l),void 0!==n.notBefore){try{e.nbf=i(n.notBefore,l)}catch(e){return d(e)}if(void 0===e.nbf)return d(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==n.expiresIn&&"object"==typeof e){try{e.exp=i(n.expiresIn,l)}catch(e){return d(e)}if(void 0===e.exp)return d(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(g).forEach((function(t){var r=g[t];if(void 0!==n[t]){if(void 0!==e[r])return d(new Error('Bad "options.'+t+'" option. The payload already has an "'+r+'" property.'));e[r]=n[t]}}));var f=n.encoding||"utf8";if("function"!=typeof s)return a.sign({header:c,payload:e,secret:t,encoding:f});s=s&&h(s),a.createSign({header:c,privateKey:t,payload:e,encoding:f}).once("error",s).once("done",(function(e){s(null,e)}))}}).call(this)}).call(this,{isBuffer:e("../is-buffer/index.js")})},{"../is-buffer/index.js":175,"./lib/psSupported":182,"./lib/timespan":183,jws:188,"lodash.includes":193,"lodash.isboolean":194,"lodash.isinteger":195,"lodash.isnumber":196,"lodash.isplainobject":197,"lodash.isstring":198,"lodash.once":199}],186:[function(e,t,r){var i=e("./lib/JsonWebTokenError"),n=e("./lib/NotBeforeError"),a=e("./lib/TokenExpiredError"),s=e("./decode"),o=e("./lib/timespan"),c=e("./lib/psSupported"),d=e("jws"),u=["RS256","RS384","RS512","ES256","ES384","ES512"],l=["RS256","RS384","RS512"],h=["HS256","HS384","HS512"];c&&(u.splice(3,0,"PS256","PS384","PS512"),l.splice(3,0,"PS256","PS384","PS512")),t.exports=function(e,t,r,c){var f;if("function"!=typeof r||c||(c=r,r={}),r||(r={}),r=Object.assign({},r),f=c||function(e,t){if(e)throw e;return t},r.clockTimestamp&&"number"!=typeof r.clockTimestamp)return f(new i("clockTimestamp must be a number"));if(void 0!==r.nonce&&("string"!=typeof r.nonce||""===r.nonce.trim()))return f(new i("nonce must be a non-empty string"));var p=r.clockTimestamp||Math.floor(Date.now()/1e3);if(!e)return f(new i("jwt must be provided"));if("string"!=typeof e)return f(new i("jwt must be a string"));var m,b=e.split(".");if(3!==b.length)return f(new i("jwt malformed"));try{m=s(e,{complete:!0})}catch(e){return f(e)}if(!m)return f(new i("invalid token"));var g,v=m.header;if("function"==typeof t){if(!c)return f(new i("verify must be called asynchronous if secret or public key is provided as a callback"));g=t}else g=function(e,r){return r(null,t)};return g(v,(function(t,s){if(t)return f(new i("error in secret or public key callback: "+t.message));var c,g=""!==b[2].trim();if(!g&&s)return f(new i("jwt signature is required"));if(g&&!s)return f(new i("secret or public key must be provided"));if(g||r.algorithms||(r.algorithms=["none"]),r.algorithms||(r.algorithms=~s.toString().indexOf("BEGIN CERTIFICATE")||~s.toString().indexOf("BEGIN PUBLIC KEY")?u:~s.toString().indexOf("BEGIN RSA PUBLIC KEY")?l:h),!~r.algorithms.indexOf(m.header.alg))return f(new i("invalid algorithm"));try{c=d.verify(e,m.header.alg,s)}catch(e){return f(e)}if(!c)return f(new i("invalid signature"));var y=m.payload;if(void 0!==y.nbf&&!r.ignoreNotBefore){if("number"!=typeof y.nbf)return f(new i("invalid nbf value"));if(y.nbf>p+(r.clockTolerance||0))return f(new n("jwt not active",new Date(1e3*y.nbf)))}if(void 0!==y.exp&&!r.ignoreExpiration){if("number"!=typeof y.exp)return f(new i("invalid exp value"));if(p>=y.exp+(r.clockTolerance||0))return f(new a("jwt expired",new Date(1e3*y.exp)))}if(r.audience){var _=Array.isArray(r.audience)?r.audience:[r.audience];if(!(Array.isArray(y.aud)?y.aud:[y.aud]).some((function(e){return _.some((function(t){return t instanceof RegExp?t.test(e):t===e}))})))return f(new i("jwt audience invalid. expected: "+_.join(" or ")))}if(r.issuer&&("string"==typeof r.issuer&&y.iss!==r.issuer||Array.isArray(r.issuer)&&-1===r.issuer.indexOf(y.iss)))return f(new i("jwt issuer invalid. expected: "+r.issuer));if(r.subject&&y.sub!==r.subject)return f(new i("jwt subject invalid. expected: "+r.subject));if(r.jwtid&&y.jti!==r.jwtid)return f(new i("jwt jwtid invalid. expected: "+r.jwtid));if(r.nonce&&y.nonce!==r.nonce)return f(new i("jwt nonce invalid. expected: "+r.nonce));if(r.maxAge){if("number"!=typeof y.iat)return f(new i("iat required when maxAge is specified"));var w=o(r.maxAge,y.iat);if(void 0===w)return f(new i('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(p>=w+(r.clockTolerance||0))return f(new a("maxAge exceeded",new Date(1e3*w)))}if(!0===r.complete){var S=m.signature;return f(null,{header:v,payload:y,signature:S})}return f(null,y)}))}},{"./decode":177,"./lib/JsonWebTokenError":179,"./lib/NotBeforeError":180,"./lib/TokenExpiredError":181,"./lib/psSupported":182,"./lib/timespan":183,jws:188}],187:[function(e,t,r){var i,n=e("safe-buffer").Buffer,a=e("crypto"),s=e("ecdsa-sig-formatter"),o=e("util"),c="secret must be a string or buffer",d="key must be a string or a buffer",u="key must be a string, a buffer or an object",l="function"==typeof a.createPublicKey;function h(e){if(!n.isBuffer(e)&&"string"!=typeof e){if(!l)throw b(d);if("object"!=typeof e)throw b(d);if("string"!=typeof e.type)throw b(d);if("string"!=typeof e.asymmetricKeyType)throw b(d);if("function"!=typeof e.export)throw b(d)}}function f(e){if(!n.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw b(u)}function p(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function m(e){var t=4-(e=e.toString()).length%4;if(4!==t)for(var r=0;r<t;++r)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function b(e){var t=[].slice.call(arguments,1),r=o.format.bind(o,e).apply(null,t);return new TypeError(r)}function g(e){var t;return t=e,n.isBuffer(t)||"string"==typeof t||(e=JSON.stringify(e)),e}function v(e){return function(t,r){!function(e){if(!n.isBuffer(e)){if("string"==typeof e)return e;if(!l)throw b(c);if("object"!=typeof e)throw b(c);if("secret"!==e.type)throw b(c);if("function"!=typeof e.export)throw b(c)}}(r),t=g(t);var i=a.createHmac("sha"+e,r);return p((i.update(t),i.digest("base64")))}}l&&(d+=" or a KeyObject",c+="or a KeyObject");var y="timingSafeEqual"in a?function(e,t){return e.byteLength===t.byteLength&&a.timingSafeEqual(e,t)}:function(t,r){return i||(i=e("buffer-equal-constant-time")),i(t,r)};function _(e){return function(t,r,i){var a=v(e)(t,i);return y(n.from(r),n.from(a))}}function w(e){return function(t,r){f(r),t=g(t);var i=a.createSign("RSA-SHA"+e);return p((i.update(t),i.sign(r,"base64")))}}function S(e){return function(t,r,i){h(i),t=g(t),r=m(r);var n=a.createVerify("RSA-SHA"+e);return n.update(t),n.verify(i,r,"base64")}}function k(e){return function(t,r){f(r),t=g(t);var i=a.createSign("RSA-SHA"+e);return p((i.update(t),i.sign({key:r,padding:a.constants.RSA_PKCS1_PSS_PADDING,saltLength:a.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function R(e){return function(t,r,i){h(i),t=g(t),r=m(r);var n=a.createVerify("RSA-SHA"+e);return n.update(t),n.verify({key:i,padding:a.constants.RSA_PKCS1_PSS_PADDING,saltLength:a.constants.RSA_PSS_SALTLEN_DIGEST},r,"base64")}}function P(e){var t=w(e);return function(){var r=t.apply(null,arguments);return r=s.derToJose(r,"ES"+e)}}function M(e){var t=S(e);return function(r,i,n){return i=s.joseToDer(i,"ES"+e).toString("base64"),t(r,i,n)}}function E(){return function(){return""}}function x(){return function(e,t){return""===t}}t.exports=function(e){var t={hs:v,rs:w,ps:k,es:P,none:E},r={hs:_,rs:S,ps:R,es:M,none:x},i=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/i);if(!i)throw b('"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".',e);var n=(i[1]||i[3]).toLowerCase(),a=i[2];return{sign:t[n](a),verify:r[n](a)}}},{"buffer-equal-constant-time":92,crypto:103,"ecdsa-sig-formatter":117,"safe-buffer":284,util:315}],188:[function(e,t,r){var i=e("./lib/sign-stream"),n=e("./lib/verify-stream");r.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],r.sign=i.sign,r.verify=n.verify,r.decode=n.decode,r.isValid=n.isValid,r.createSign=function(e){return new i(e)},r.createVerify=function(e){return new n(e)}},{"./lib/sign-stream":190,"./lib/verify-stream":192}],189:[function(e,t,r){(function(r){(function(){var i=e("safe-buffer").Buffer,n=e("stream");function a(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=i.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=i.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,r.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}e("util").inherits(a,n),a.prototype.write=function(e){this.buffer=i.concat([this.buffer,i.from(e)]),this.emit("data",e)},a.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1},t.exports=a}).call(this)}).call(this,e("_process"))},{_process:257,"safe-buffer":284,stream:306,util:315}],190:[function(e,t,r){var i=e("safe-buffer").Buffer,n=e("./data-stream"),a=e("jwa"),s=e("stream"),o=e("./tostring"),c=e("util");function d(e,t){return i.from(e,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function u(e){var t=e.header,r=e.payload,i=e.secret||e.privateKey,n=e.encoding,s=a(t.alg),u=function(e,t,r){r=r||"utf8";var i=d(o(e),"binary"),n=d(o(t),r);return c.format("%s.%s",i,n)}(t,r,n),l=s.sign(u,i);return c.format("%s.%s",u,l)}function l(e){var t=e.secret||e.privateKey||e.key,r=new n(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=r,this.payload=new n(e.payload),this.secret.once("close",function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once("close",function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}c.inherits(l,s),l.prototype.sign=function(){try{var e=u({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",e),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},l.sign=u,t.exports=l},{"./data-stream":189,"./tostring":191,jwa:187,"safe-buffer":284,stream:306,util:315}],191:[function(e,t,r){var i=e("buffer").Buffer;t.exports=function(e){return"string"==typeof e?e:"number"==typeof e||i.isBuffer(e)?e.toString():JSON.stringify(e)}},{buffer:94}],192:[function(e,t,r){var i=e("safe-buffer").Buffer,n=e("./data-stream"),a=e("jwa"),s=e("stream"),o=e("./tostring"),c=e("util"),d=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function u(e){if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e))return e;try{return JSON.parse(e)}catch(e){return}}function l(e){var t=e.split(".",1)[0];return u(i.from(t,"base64").toString("binary"))}function h(e){return e.split(".")[2]}function f(e){return d.test(e)&&!!l(e)}function p(e,t,r){if(!t){var i=new Error("Missing algorithm parameter for jws.verify");throw i.code="MISSING_ALGORITHM",i}var n=h(e=o(e)),s=function(e){return e.split(".",2).join(".")}(e);return a(t).verify(s,n,r)}function m(e,t){if(t=t||{},!f(e=o(e)))return null;var r=l(e);if(!r)return null;var n=function(e,t){t=t||"utf8";var r=e.split(".")[1];return i.from(r,"base64").toString(t)}(e);return("JWT"===r.typ||t.json)&&(n=JSON.parse(n,t.encoding)),{header:r,payload:n,signature:h(e)}}function b(e){var t=(e=e||{}).secret||e.publicKey||e.key,r=new n(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=r,this.signature=new n(e.signature),this.secret.once("close",function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once("close",function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}c.inherits(b,s),b.prototype.verify=function(){try{var e=p(this.signature.buffer,this.algorithm,this.key.buffer),t=m(this.signature.buffer,this.encoding);return this.emit("done",e,t),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},b.decode=m,b.isValid=f,b.verify=p,t.exports=b},{"./data-stream":189,"./tostring":191,jwa:187,"safe-buffer":284,stream:306,util:315}],193:[function(e,t,r){var i=1/0,n=9007199254740991,a=17976931348623157e292,s=NaN,o="[object Arguments]",c="[object Function]",d="[object GeneratorFunction]",u="[object String]",l="[object Symbol]",h=/^\s+|\s+$/g,f=/^[-+]0x[0-9a-f]+$/i,p=/^0b[01]+$/i,m=/^0o[0-7]+$/i,b=/^(?:0|[1-9]\d*)$/,g=parseInt;function v(e){return e!=e}function y(e,t){return function(e,t){for(var r=-1,i=e?e.length:0,n=Array(i);++r<i;)n[r]=t(e[r],r,e);return n}(t,(function(t){return e[t]}))}var _,w,S=Object.prototype,k=S.hasOwnProperty,R=S.toString,P=S.propertyIsEnumerable,M=(_=Object.keys,w=Object,function(e){return _(w(e))}),E=Math.max;function x(e,t){var r=I(e)||function(e){return function(e){return A(e)&&D(e)}(e)&&k.call(e,"callee")&&(!P.call(e,"callee")||R.call(e)==o)}(e)?function(e,t){for(var r=-1,i=Array(e);++r<e;)i[r]=t(r);return i}(e.length,String):[],i=r.length,n=!!i;for(var a in e)!t&&!k.call(e,a)||n&&("length"==a||C(a,i))||r.push(a);return r}function T(e){if(r=(t=e)&&t.constructor,i="function"==typeof r&&r.prototype||S,t!==i)return M(e);var t,r,i,n=[];for(var a in Object(e))k.call(e,a)&&"constructor"!=a&&n.push(a);return n}function C(e,t){return!!(t=null==t?n:t)&&("number"==typeof e||b.test(e))&&e>-1&&e%1==0&&e<t}var I=Array.isArray;function D(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=O(e)?R.call(e):"";return t==c||t==d}(e)}function O(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function A(e){return!!e&&"object"==typeof e}t.exports=function(e,t,r,n){var o;e=D(e)?e:(o=e)?y(o,function(e){return D(e)?x(e):T(e)}(o)):[],r=r&&!n?function(e){var t=function(e){if(!e)return 0===e?e:0;if(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||A(e)&&R.call(e)==l}(e))return s;if(O(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=O(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(h,"");var r=p.test(e);return r||m.test(e)?g(e.slice(2),r?2:8):f.test(e)?s:+e}(e),e===i||e===-i){return(e<0?-1:1)*a}return e==e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}(r):0;var c=e.length;return r<0&&(r=E(c+r,0)),function(e){return"string"==typeof e||!I(e)&&A(e)&&R.call(e)==u}(e)?r<=c&&e.indexOf(t,r)>-1:!!c&&function(e,t,r){if(t!=t)return function(e,t,r,i){for(var n=e.length,a=r+(i?1:-1);i?a--:++a<n;)if(t(e[a],a,e))return a;return-1}(e,v,r);for(var i=r-1,n=e.length;++i<n;)if(e[i]===t)return i;return-1}(e,t,r)>-1}},{}],194:[function(e,t,r){var i=Object.prototype.toString;t.exports=function(e){return!0===e||!1===e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Boolean]"==i.call(e)}},{}],195:[function(e,t,r){var i=1/0,n=17976931348623157e292,a=NaN,s="[object Symbol]",o=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,d=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt,h=Object.prototype.toString;function f(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}t.exports=function(e){return"number"==typeof e&&e==function(e){var t=function(e){if(!e)return 0===e?e:0;if(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&h.call(e)==s}(e))return a;if(f(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=f(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var r=d.test(e);return r||u.test(e)?l(e.slice(2),r?2:8):c.test(e)?a:+e}(e),e===i||e===-i){return(e<0?-1:1)*n}return e==e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}(e)}},{}],196:[function(e,t,r){var i=Object.prototype.toString;t.exports=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Number]"==i.call(e)}},{}],197:[function(e,t,r){var i,n,a=Function.prototype,s=Object.prototype,o=a.toString,c=s.hasOwnProperty,d=o.call(Object),u=s.toString,l=(i=Object.getPrototypeOf,n=Object,function(e){return i(n(e))});t.exports=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=u.call(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e))return!1;var t=l(e);if(null===t)return!0;var r=c.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&o.call(r)==d}},{}],198:[function(e,t,r){var i=Object.prototype.toString,n=Array.isArray;t.exports=function(e){return"string"==typeof e||!n(e)&&function(e){return!!e&&"object"==typeof e}(e)&&"[object String]"==i.call(e)}},{}],199:[function(e,t,r){var i="Expected a function",n=1/0,a=17976931348623157e292,s=NaN,o="[object Symbol]",c=/^\s+|\s+$/g,d=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,l=/^0o[0-7]+$/i,h=parseInt,f=Object.prototype.toString;function p(e,t){var r;if("function"!=typeof t)throw new TypeError(i);return e=function(e){var t=function(e){if(!e)return 0===e?e:0;if(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&f.call(e)==o}(e))return s;if(m(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=m(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(c,"");var r=u.test(e);return r||l.test(e)?h(e.slice(2),r?2:8):d.test(e)?s:+e}(e),e===n||e===-n){return(e<0?-1:1)*a}return e==e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=void 0),r}}function m(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}t.exports=function(e){return p(2,e)}},{}],200:[function(e,t,r){"use strict";var i=e("inherits"),n=e("hash-base"),a=e("safe-buffer").Buffer,s=new Array(16);function o(){n.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(e,t){return e<<t|e>>>32-t}function d(e,t,r,i,n,a,s){return c(e+(t&r|~t&i)+n+a|0,s)+t|0}function u(e,t,r,i,n,a,s){return c(e+(t&i|r&~i)+n+a|0,s)+t|0}function l(e,t,r,i,n,a,s){return c(e+(t^r^i)+n+a|0,s)+t|0}function h(e,t,r,i,n,a,s){return c(e+(r^(t|~i))+n+a|0,s)+t|0}i(o,n),o.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,i=this._b,n=this._c,a=this._d;r=d(r,i,n,a,e[0],3614090360,7),a=d(a,r,i,n,e[1],3905402710,12),n=d(n,a,r,i,e[2],606105819,17),i=d(i,n,a,r,e[3],3250441966,22),r=d(r,i,n,a,e[4],4118548399,7),a=d(a,r,i,n,e[5],1200080426,12),n=d(n,a,r,i,e[6],2821735955,17),i=d(i,n,a,r,e[7],4249261313,22),r=d(r,i,n,a,e[8],1770035416,7),a=d(a,r,i,n,e[9],2336552879,12),n=d(n,a,r,i,e[10],4294925233,17),i=d(i,n,a,r,e[11],2304563134,22),r=d(r,i,n,a,e[12],1804603682,7),a=d(a,r,i,n,e[13],4254626195,12),n=d(n,a,r,i,e[14],2792965006,17),r=u(r,i=d(i,n,a,r,e[15],1236535329,22),n,a,e[1],4129170786,5),a=u(a,r,i,n,e[6],3225465664,9),n=u(n,a,r,i,e[11],643717713,14),i=u(i,n,a,r,e[0],3921069994,20),r=u(r,i,n,a,e[5],3593408605,5),a=u(a,r,i,n,e[10],38016083,9),n=u(n,a,r,i,e[15],3634488961,14),i=u(i,n,a,r,e[4],3889429448,20),r=u(r,i,n,a,e[9],568446438,5),a=u(a,r,i,n,e[14],3275163606,9),n=u(n,a,r,i,e[3],4107603335,14),i=u(i,n,a,r,e[8],1163531501,20),r=u(r,i,n,a,e[13],2850285829,5),a=u(a,r,i,n,e[2],4243563512,9),n=u(n,a,r,i,e[7],1735328473,14),r=l(r,i=u(i,n,a,r,e[12],2368359562,20),n,a,e[5],4294588738,4),a=l(a,r,i,n,e[8],2272392833,11),n=l(n,a,r,i,e[11],1839030562,16),i=l(i,n,a,r,e[14],4259657740,23),r=l(r,i,n,a,e[1],2763975236,4),a=l(a,r,i,n,e[4],1272893353,11),n=l(n,a,r,i,e[7],4139469664,16),i=l(i,n,a,r,e[10],3200236656,23),r=l(r,i,n,a,e[13],681279174,4),a=l(a,r,i,n,e[0],3936430074,11),n=l(n,a,r,i,e[3],3572445317,16),i=l(i,n,a,r,e[6],76029189,23),r=l(r,i,n,a,e[9],3654602809,4),a=l(a,r,i,n,e[12],3873151461,11),n=l(n,a,r,i,e[15],530742520,16),r=h(r,i=l(i,n,a,r,e[2],3299628645,23),n,a,e[0],4096336452,6),a=h(a,r,i,n,e[7],1126891415,10),n=h(n,a,r,i,e[14],2878612391,15),i=h(i,n,a,r,e[5],4237533241,21),r=h(r,i,n,a,e[12],1700485571,6),a=h(a,r,i,n,e[3],2399980690,10),n=h(n,a,r,i,e[10],4293915773,15),i=h(i,n,a,r,e[1],2240044497,21),r=h(r,i,n,a,e[8],1873313359,6),a=h(a,r,i,n,e[15],4264355552,10),n=h(n,a,r,i,e[6],2734768916,15),i=h(i,n,a,r,e[13],1309151649,21),r=h(r,i,n,a,e[4],4149444226,6),a=h(a,r,i,n,e[11],3174756917,10),n=h(n,a,r,i,e[2],718787259,15),i=h(i,n,a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+n|0,this._d=this._d+a|0},o.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=a.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=o},{"hash-base":159,inherits:174,"safe-buffer":284}],201:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Consumer=void 0;const i=e("./Logger"),n=e("./EnhancedEventEmitter"),a=e("./errors"),s=new i.Logger("Consumer");class o extends n.EnhancedEventEmitter{constructor({id:e,localId:t,producerId:r,rtpReceiver:i,track:a,rtpParameters:o,appData:c}){super(),this._closed=!1,this._observer=new n.EnhancedEventEmitter,s.debug("constructor()"),this._id=e,this._localId=t,this._producerId=r,this._rtpReceiver=i,this._track=a,this._rtpParameters=o,this._paused=!a.enabled,this._appData=c||{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get producerId(){return this._producerId}get closed(){return this._closed}get kind(){return this._track.kind}get rtpReceiver(){return this._rtpReceiver}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(s.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(s.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new a.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){s.debug("pause()"),this._closed?s.error("pause() | Consumer closed"):this._paused?s.debug("pause() | Consumer is already paused"):(this._paused=!0,this._track.enabled=!1,this.emit("@pause"),this._observer.safeEmit("pause"))}resume(){s.debug("resume()"),this._closed?s.error("resume() | Consumer closed"):this._paused?(this._paused=!1,this._track.enabled=!0,this.emit("@resume"),this._observer.safeEmit("resume")):s.debug("resume() | Consumer is already resumed")}onTrackEnded(){s.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){try{this._track.removeEventListener("ended",this.onTrackEnded),this._track.stop()}catch(e){}}}r.Consumer=o},{"./EnhancedEventEmitter":205,"./Logger":206,"./errors":211}],202:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.DataConsumer=void 0;const i=e("./Logger"),n=e("./EnhancedEventEmitter"),a=new i.Logger("DataConsumer");class s extends n.EnhancedEventEmitter{constructor({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:i,appData:s}){super(),this._closed=!1,this._observer=new n.EnhancedEventEmitter,a.debug("constructor()"),this._id=e,this._dataProducerId=t,this._dataChannel=r,this._sctpStreamParameters=i,this._appData=s||{},this.handleDataChannel()}get id(){return this._id}get dataProducerId(){return this._dataProducerId}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get binaryType(){return this._dataChannel.binaryType}set binaryType(e){this._dataChannel.binaryType=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(a.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(a.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(a.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;let{error:t}=e;t||(t=new Error("unknown DataChannel error")),"sctp-failure"===t.errorDetail?a.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):a.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(a.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(e=>{this._closed||this.safeEmit("message",e.data)}))}}r.DataConsumer=s},{"./EnhancedEventEmitter":205,"./Logger":206}],203:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.DataProducer=void 0;const i=e("./Logger"),n=e("./EnhancedEventEmitter"),a=e("./errors"),s=new i.Logger("DataProducer");class o extends n.EnhancedEventEmitter{constructor({id:e,dataChannel:t,sctpStreamParameters:r,appData:i}){super(),this._closed=!1,this._observer=new n.EnhancedEventEmitter,s.debug("constructor()"),this._id=e,this._dataChannel=t,this._sctpStreamParameters=r,this._appData=i||{},this.handleDataChannel()}get id(){return this._id}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get bufferedAmount(){return this._dataChannel.bufferedAmount}get bufferedAmountLowThreshold(){return this._dataChannel.bufferedAmountLowThreshold}set bufferedAmountLowThreshold(e){this._dataChannel.bufferedAmountLowThreshold=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(s.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(s.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}send(e){if(s.debug("send()"),this._closed)throw new a.InvalidStateError("closed");this._dataChannel.send(e)}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(s.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;let{error:t}=e;t||(t=new Error("unknown DataChannel error")),"sctp-failure"===t.errorDetail?s.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):s.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(s.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(()=>{this._closed||s.warn('DataChannel "message" event in a DataProducer, message discarded')})),this._dataChannel.addEventListener("bufferedamountlow",(()=>{this._closed||this.safeEmit("bufferedamountlow")}))}}r.DataProducer=o},{"./EnhancedEventEmitter":205,"./Logger":206,"./errors":211}],204:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Device=void 0,r.detectDevice=M;const s=e("ua-parser-js"),o=e("./Logger"),c=e("./EnhancedEventEmitter"),d=e("./errors"),u=a(e("./utils")),l=a(e("./ortc")),h=e("./Transport"),f=e("./handlers/Chrome111"),p=e("./handlers/Chrome74"),m=e("./handlers/Chrome70"),b=e("./handlers/Chrome67"),g=e("./handlers/Chrome55"),v=e("./handlers/Firefox120"),y=e("./handlers/Firefox60"),_=e("./handlers/Safari12"),w=e("./handlers/Safari11"),S=e("./handlers/Edge11"),k=e("./handlers/ReactNativeUnifiedPlan"),R=e("./handlers/ReactNative"),P=new o.Logger("Device");function M(){if("object"==typeof navigator&&"ReactNative"===navigator.product)return P.debug("detectDevice() | React-Native detected"),"undefined"==typeof RTCPeerConnection?void P.warn("detectDevice() | unsupported react-native-webrtc without RTCPeerConnection, forgot to call registerGlobals()?"):"undefined"!=typeof RTCRtpTransceiver?(P.debug("detectDevice() | ReactNative UnifiedPlan handler chosen"),"ReactNativeUnifiedPlan"):(P.debug("detectDevice() | ReactNative PlanB handler chosen"),"ReactNative");if("object"!=typeof navigator||"string"!=typeof navigator.userAgent)P.warn("detectDevice() | unknown device");else{const e=navigator.userAgent,t=new s.UAParser(e);P.debug("detectDevice() | browser detected [ua:%s, parsed:%o]",e,t.getResult());const r=t.getBrowser(),i=r.name?.toLowerCase(),n=parseInt(r.major??"0"),a=t.getEngine(),o=a.name?.toLowerCase(),c=t.getOS(),d=c.name?.toLowerCase(),u=parseFloat(c.version??"0"),l=t.getDevice(),h=l.model?.toLowerCase(),f="ios"===d||"ipad"===h,p=i&&["chrome","chromium","mobile chrome","chrome webview","chrome headless"].includes(i),m=i&&["firefox","mobile firefox","mobile focus"].includes(i),b=i&&["safari","mobile safari"].includes(i),g=i&&["edge"].includes(i);if((p||g)&&!f&&n>=111)return"Chrome111";if(p&&!f&&n>=74||g&&!f&&n>=88)return"Chrome74";if(p&&!f&&n>=70)return"Chrome70";if(p&&!f&&n>=67)return"Chrome67";if(p&&!f&&n>=55)return"Chrome55";if(m&&!f&&n>=120)return"Firefox120";if(m&&!f&&n>=60)return"Firefox60";if(m&&f&&u>=14.3)return"Safari12";if(b&&n>=12&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(b&&n>=11)return"Safari11";if(g&&!f&&n>=11&&n<=18)return"Edge11";if("webkit"===o&&f&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if("blink"===o){const t=e.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);if(t){const e=Number(t[1]);return e>=111?"Chrome111":e>=74?"Chrome74":e>=70?"Chrome70":e>=67?"Chrome67":"Chrome55"}return"Chrome111"}P.warn("detectDevice() | browser not supported [name:%s, version:%s]",i,n)}}r.Device=class{constructor({handlerName:e,handlerFactory:t,Handler:r}={}){if(this._loaded=!1,this._observer=new c.EnhancedEventEmitter,P.debug("constructor()"),r){if(P.warn("constructor() | Handler option is DEPRECATED, use handlerName or handlerFactory instead"),"string"!=typeof r)throw new TypeError("non string Handler option no longer supported, use handlerFactory instead");e=r}if(e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(t)this._handlerFactory=t;else{if(e)P.debug("constructor() | handler given: %s",e);else{if(!(e=M()))throw new d.UnsupportedError("device not supported");P.debug("constructor() | detected handler: %s",e)}switch(e){case"Chrome111":this._handlerFactory=f.Chrome111.createFactory();break;case"Chrome74":this._handlerFactory=p.Chrome74.createFactory();break;case"Chrome70":this._handlerFactory=m.Chrome70.createFactory();break;case"Chrome67":this._handlerFactory=b.Chrome67.createFactory();break;case"Chrome55":this._handlerFactory=g.Chrome55.createFactory();break;case"Firefox120":this._handlerFactory=v.Firefox120.createFactory();break;case"Firefox60":this._handlerFactory=y.Firefox60.createFactory();break;case"Safari12":this._handlerFactory=_.Safari12.createFactory();break;case"Safari11":this._handlerFactory=w.Safari11.createFactory();break;case"Edge11":this._handlerFactory=S.Edge11.createFactory();break;case"ReactNativeUnifiedPlan":this._handlerFactory=k.ReactNativeUnifiedPlan.createFactory();break;case"ReactNative":this._handlerFactory=R.ReactNative.createFactory();break;default:throw new TypeError(`unknown handlerName "${e}"`)}}const i=this._handlerFactory();this._handlerName=i.name,i.close(),this._extendedRtpCapabilities=void 0,this._recvRtpCapabilities=void 0,this._canProduceByKind={audio:!1,video:!1},this._sctpCapabilities=void 0}get handlerName(){return this._handlerName}get loaded(){return this._loaded}get rtpCapabilities(){if(!this._loaded)throw new d.InvalidStateError("not loaded");return this._recvRtpCapabilities}get sctpCapabilities(){if(!this._loaded)throw new d.InvalidStateError("not loaded");return this._sctpCapabilities}get observer(){return this._observer}async load({routerRtpCapabilities:e}){let t;P.debug("load() [routerRtpCapabilities:%o]",e);try{if(this._loaded)throw new d.InvalidStateError("already loaded");const r=u.clone(e);l.validateRtpCapabilities(r),t=this._handlerFactory();const i=await t.getNativeRtpCapabilities();P.debug("load() | got native RTP capabilities:%o",i);const n=u.clone(i);l.validateRtpCapabilities(n),this._extendedRtpCapabilities=l.getExtendedRtpCapabilities(n,r),P.debug("load() | got extended RTP capabilities:%o",this._extendedRtpCapabilities),this._canProduceByKind.audio=l.canSend("audio",this._extendedRtpCapabilities),this._canProduceByKind.video=l.canSend("video",this._extendedRtpCapabilities),this._recvRtpCapabilities=l.getRecvRtpCapabilities(this._extendedRtpCapabilities),l.validateRtpCapabilities(this._recvRtpCapabilities),P.debug("load() | got receiving RTP capabilities:%o",this._recvRtpCapabilities),this._sctpCapabilities=await t.getNativeSctpCapabilities(),P.debug("load() | got native SCTP capabilities:%o",this._sctpCapabilities),l.validateSctpCapabilities(this._sctpCapabilities),P.debug("load() succeeded"),this._loaded=!0,t.close()}catch(e){throw t&&t.close(),e}}canProduce(e){if(!this._loaded)throw new d.InvalidStateError("not loaded");if("audio"!==e&&"video"!==e)throw new TypeError(`invalid kind "${e}"`);return this._canProduceByKind[e]}createSendTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,appData:d}){return P.debug("createSendTransport()"),this.createTransport({direction:"send",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,appData:d})}createRecvTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,appData:d}){return P.debug("createRecvTransport()"),this.createTransport({direction:"recv",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,appData:d})}createTransport({direction:e,id:t,iceParameters:r,iceCandidates:i,dtlsParameters:n,sctpParameters:a,iceServers:s,iceTransportPolicy:o,additionalSettings:c,proprietaryConstraints:u,appData:l}){if(!this._loaded)throw new d.InvalidStateError("not loaded");if("string"!=typeof t)throw new TypeError("missing id");if("object"!=typeof r)throw new TypeError("missing iceParameters");if(!Array.isArray(i))throw new TypeError("missing iceCandidates");if("object"!=typeof n)throw new TypeError("missing dtlsParameters");if(a&&"object"!=typeof a)throw new TypeError("wrong sctpParameters");if(l&&"object"!=typeof l)throw new TypeError("if given, appData must be an object");const f=new h.Transport({direction:e,id:t,iceParameters:r,iceCandidates:i,dtlsParameters:n,sctpParameters:a,iceServers:s,iceTransportPolicy:o,additionalSettings:c,proprietaryConstraints:u,appData:l,handlerFactory:this._handlerFactory,extendedRtpCapabilities:this._extendedRtpCapabilities,canProduceByKind:this._canProduceByKind});return this._observer.safeEmit("newtransport",f),f}}},{"./EnhancedEventEmitter":205,"./Logger":206,"./Transport":210,"./errors":211,"./handlers/Chrome111":212,"./handlers/Chrome55":213,"./handlers/Chrome67":214,"./handlers/Chrome70":215,"./handlers/Chrome74":216,"./handlers/Edge11":217,"./handlers/Firefox120":218,"./handlers/Firefox60":219,"./handlers/ReactNative":221,"./handlers/ReactNativeUnifiedPlan":222,"./handlers/Safari11":223,"./handlers/Safari12":224,"./ortc":233,"./utils":236,"ua-parser-js":309}],205:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.EnhancedEventEmitter=void 0;const i=e("npm-events-package"),n=new(e("./Logger").Logger)("EnhancedEventEmitter");class a extends i.EventEmitter{constructor(){super(),this.setMaxListeners(1/0)}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...t){const r=super.listenerCount(e);try{return super.emit(e,...t)}catch(t){return n.error("safeEmit() | event listener threw an error [eventName:%s]:%o",e,t),Boolean(r)}}on(e,t){return super.on(e,t),this}off(e,t){return super.off(e,t),this}addListener(e,t){return super.on(e,t),this}prependListener(e,t){return super.prependListener(e,t),this}once(e,t){return super.once(e,t),this}prependOnceListener(e,t){return super.prependOnceListener(e,t),this}removeListener(e,t){return super.off(e,t),this}removeAllListeners(e){return super.removeAllListeners(e),this}listenerCount(e){return super.listenerCount(e)}listeners(e){return super.listeners(e)}rawListeners(e){return super.rawListeners(e)}}r.EnhancedEventEmitter=a},{"./Logger":206,"npm-events-package":242}],206:[function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Logger=void 0;const n=i(e("debug")),a="mediasoup-client";r.Logger=class{constructor(e){e?(this._debug=(0,n.default)(`${a}:${e}`),this._warn=(0,n.default)(`${a}:WARN:${e}`),this._error=(0,n.default)(`${a}:ERROR:${e}`)):(this._debug=(0,n.default)(a),this._warn=(0,n.default)(`${a}:WARN`),this._error=(0,n.default)(`${a}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}}},{debug:104}],207:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Producer=void 0;const i=e("./Logger"),n=e("./EnhancedEventEmitter"),a=e("./errors"),s=new i.Logger("Producer");class o extends n.EnhancedEventEmitter{constructor({id:e,localId:t,rtpSender:r,track:i,rtpParameters:a,stopTracks:o,disableTrackOnPause:c,zeroRtpOnPause:d,appData:u}){super(),this._closed=!1,this._observer=new n.EnhancedEventEmitter,s.debug("constructor()"),this._id=e,this._localId=t,this._rtpSender=r,this._track=i,this._kind=i.kind,this._rtpParameters=a,this._paused=!!c&&!i.enabled,this._maxSpatialLayer=void 0,this._stopTracks=o,this._disableTrackOnPause=c,this._zeroRtpOnPause=d,this._appData=u||{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get closed(){return this._closed}get kind(){return this._kind}get rtpSender(){return this._rtpSender}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get maxSpatialLayer(){return this._maxSpatialLayer}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(s.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(s.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new a.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){s.debug("pause()"),this._closed?s.error("pause() | Producer closed"):(this._paused=!0,this._track&&this._disableTrackOnPause&&(this._track.enabled=!1),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@pause",e,t)})).catch((()=>{})),this._observer.safeEmit("pause"))}resume(){s.debug("resume()"),this._closed?s.error("resume() | Producer closed"):(this._paused=!1,this._track&&this._disableTrackOnPause&&(this._track.enabled=!0),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@resume",e,t)})).catch((()=>{})),this._observer.safeEmit("resume"))}async replaceTrack({track:e}){if(s.debug("replaceTrack() [track:%o]",e),this._closed){if(e&&this._stopTracks)try{e.stop()}catch(e){}throw new a.InvalidStateError("closed")}if(e&&"ended"===e.readyState)throw new a.InvalidStateError("track ended");e!==this._track?(await new Promise(((t,r)=>{this.safeEmit("@replacetrack",e,t,r)})),this.destroyTrack(),this._track=e,this._track&&this._disableTrackOnPause&&(this._paused?this._paused&&(this._track.enabled=!1):this._track.enabled=!0),this.handleTrack()):s.debug("replaceTrack() | same track, ignored")}async setMaxSpatialLayer(e){if(this._closed)throw new a.InvalidStateError("closed");if("video"!==this._kind)throw new a.UnsupportedError("not a video Producer");if("number"!=typeof e)throw new TypeError("invalid spatialLayer");e!==this._maxSpatialLayer&&(await new Promise(((t,r)=>{this.safeEmit("@setmaxspatiallayer",e,t,r)})).catch((()=>{})),this._maxSpatialLayer=e)}async setRtpEncodingParameters(e){if(this._closed)throw new a.InvalidStateError("closed");if("object"!=typeof e)throw new TypeError("invalid params");await new Promise(((t,r)=>{this.safeEmit("@setrtpencodingparameters",e,t,r)}))}onTrackEnded(){s.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track&&this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){if(this._track)try{this._track.removeEventListener("ended",this.onTrackEnded),this._stopTracks&&this._track.stop()}catch(e){}}}r.Producer=o},{"./EnhancedEventEmitter":205,"./Logger":206,"./errors":211}],208:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},{}],209:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},{}],210:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Transport=void 0;const o=e("awaitqueue"),c=s(e("queue-microtask")),d=e("./Logger"),u=e("./EnhancedEventEmitter"),l=e("./errors"),h=a(e("./utils")),f=a(e("./ortc")),p=e("./Producer"),m=e("./Consumer"),b=e("./DataProducer"),g=e("./DataConsumer"),v=new d.Logger("Transport");class y{constructor(e){this.consumerOptions=e,this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class _ extends u.EnhancedEventEmitter{constructor({direction:e,id:t,iceParameters:r,iceCandidates:i,dtlsParameters:n,sctpParameters:a,iceServers:s,iceTransportPolicy:c,additionalSettings:d,proprietaryConstraints:l,appData:f,handlerFactory:p,extendedRtpCapabilities:m,canProduceByKind:b}){super(),this._closed=!1,this._iceGatheringState="new",this._connectionState="new",this._producers=new Map,this._consumers=new Map,this._dataProducers=new Map,this._dataConsumers=new Map,this._probatorConsumerCreated=!1,this._awaitQueue=new o.AwaitQueue,this._pendingConsumerTasks=[],this._consumerCreationInProgress=!1,this._pendingPauseConsumers=new Map,this._consumerPauseInProgress=!1,this._pendingResumeConsumers=new Map,this._consumerResumeInProgress=!1,this._pendingCloseConsumers=new Map,this._consumerCloseInProgress=!1,this._observer=new u.EnhancedEventEmitter,v.debug("constructor() [id:%s, direction:%s]",t,e),this._id=t,this._direction=e,this._extendedRtpCapabilities=m,this._canProduceByKind=b,this._maxSctpMessageSize=a?a.maxMessageSize:null;const g=h.clone(d)||{};delete g.iceServers,delete g.iceTransportPolicy,delete g.bundlePolicy,delete g.rtcpMuxPolicy,delete g.sdpSemantics,this._handler=p(),this._handler.run({direction:e,iceParameters:r,iceCandidates:i,dtlsParameters:n,sctpParameters:a,iceServers:s,iceTransportPolicy:c,additionalSettings:g,proprietaryConstraints:l,extendedRtpCapabilities:m}),this._appData=f||{},this.handleHandler()}get id(){return this._id}get closed(){return this._closed}get direction(){return this._direction}get handler(){return this._handler}get iceGatheringState(){return this._iceGatheringState}get connectionState(){return this._connectionState}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){if(!this._closed){v.debug("close()"),this._closed=!0,this._awaitQueue.stop(),this._handler.close(),this._connectionState="closed";for(const e of this._producers.values())e.transportClosed();this._producers.clear();for(const e of this._consumers.values())e.transportClosed();this._consumers.clear();for(const e of this._dataProducers.values())e.transportClosed();this._dataProducers.clear();for(const e of this._dataConsumers.values())e.transportClosed();this._dataConsumers.clear(),this._observer.safeEmit("close")}}async getStats(){if(this._closed)throw new l.InvalidStateError("closed");return this._handler.getTransportStats()}async restartIce({iceParameters:e}){if(v.debug("restartIce()"),this._closed)throw new l.InvalidStateError("closed");if(!e)throw new TypeError("missing iceParameters");return this._awaitQueue.push((async()=>await this._handler.restartIce(e)),"transport.restartIce()")}async updateIceServers({iceServers:e}={}){if(v.debug("updateIceServers()"),this._closed)throw new l.InvalidStateError("closed");if(!Array.isArray(e))throw new TypeError("missing iceServers");return this._awaitQueue.push((async()=>this._handler.updateIceServers(e)),"transport.updateIceServers()")}async produce({track:e,encodings:t,codecOptions:r,codec:i,stopTracks:n=!0,disableTrackOnPause:a=!0,zeroRtpOnPause:s=!1,onRtpSender:o,appData:c={}}={}){if(v.debug("produce() [track:%o]",e),this._closed)throw new l.InvalidStateError("closed");if(!e)throw new TypeError("missing track");if("send"!==this._direction)throw new l.UnsupportedError("not a sending Transport");if(!this._canProduceByKind[e.kind])throw new l.UnsupportedError(`cannot produce ${e.kind}`);if("ended"===e.readyState)throw new l.InvalidStateError("track ended");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("produce"))throw new TypeError('no "produce" listener set into this transport');if(c&&"object"!=typeof c)throw new TypeError("if given, appData must be an object");return this._awaitQueue.push((async()=>{let d;if(t&&!Array.isArray(t))throw TypeError("encodings must be an array");t&&0===t.length?d=void 0:t&&(d=t.map((e=>{const t={active:!0};return!1===e.active&&(t.active=!1),"boolean"==typeof e.dtx&&(t.dtx=e.dtx),"string"==typeof e.scalabilityMode&&(t.scalabilityMode=e.scalabilityMode),"number"==typeof e.scaleResolutionDownBy&&(t.scaleResolutionDownBy=e.scaleResolutionDownBy),"number"==typeof e.maxBitrate&&(t.maxBitrate=e.maxBitrate),"number"==typeof e.maxFramerate&&(t.maxFramerate=e.maxFramerate),"boolean"==typeof e.adaptivePtime&&(t.adaptivePtime=e.adaptivePtime),"string"==typeof e.priority&&(t.priority=e.priority),"string"==typeof e.networkPriority&&(t.networkPriority=e.networkPriority),t})));const{localId:u,rtpParameters:l,rtpSender:h}=await this._handler.send({track:e,encodings:d,codecOptions:r,codec:i,onRtpSender:o});try{f.validateRtpParameters(l);const{id:t}=await new Promise(((t,r)=>{this.safeEmit("produce",{kind:e.kind,rtpParameters:l,appData:c},t,r)})),r=new p.Producer({id:t,localId:u,rtpSender:h,track:e,rtpParameters:l,stopTracks:n,disableTrackOnPause:a,zeroRtpOnPause:s,appData:c});return this._producers.set(r.id,r),this.handleProducer(r),this._observer.safeEmit("newproducer",r),r}catch(e){throw this._handler.stopSending(u).catch((()=>{})),e}}),"transport.produce()").catch((t=>{if(n)try{e.stop()}catch(e){}throw t}))}async consume({id:e,producerId:t,kind:r,rtpParameters:i,streamId:n,onRtpReceiver:a,appData:s={}}){if(v.debug("consume()"),this._closed)throw new l.InvalidStateError("closed");if("recv"!==this._direction)throw new l.UnsupportedError("not a receiving Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing producerId");if("audio"!==r&&"video"!==r)throw new TypeError(`invalid kind '${r}'`);if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(s&&"object"!=typeof s)throw new TypeError("if given, appData must be an object");const o=h.clone(i);if(!f.canReceive(o,this._extendedRtpCapabilities))throw new l.UnsupportedError("cannot consume this Producer");const d=new y({id:e,producerId:t,kind:r,rtpParameters:o,streamId:n,onRtpReceiver:a,appData:s});return this._pendingConsumerTasks.push(d),(0,c.default)((()=>{this._closed||!1===this._consumerCreationInProgress&&this.createPendingConsumers()})),d.promise}async produceData({ordered:e=!0,maxPacketLifeTime:t,maxRetransmits:r,label:i="",protocol:n="",appData:a={}}={}){if(v.debug("produceData()"),this._closed)throw new l.InvalidStateError("closed");if("send"!==this._direction)throw new l.UnsupportedError("not a sending Transport");if(!this._maxSctpMessageSize)throw new l.UnsupportedError("SCTP not enabled by remote Transport");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("producedata"))throw new TypeError('no "producedata" listener set into this transport');if(a&&"object"!=typeof a)throw new TypeError("if given, appData must be an object");return(t||r)&&(e=!1),this._awaitQueue.push((async()=>{const{dataChannel:s,sctpStreamParameters:o}=await this._handler.sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n});f.validateSctpStreamParameters(o);const{id:c}=await new Promise(((e,t)=>{this.safeEmit("producedata",{sctpStreamParameters:o,label:i,protocol:n,appData:a},e,t)})),d=new b.DataProducer({id:c,dataChannel:s,sctpStreamParameters:o,appData:a});return this._dataProducers.set(d.id,d),this.handleDataProducer(d),this._observer.safeEmit("newdataproducer",d),d}),"transport.produceData()")}async consumeData({id:e,dataProducerId:t,sctpStreamParameters:r,label:i="",protocol:n="",appData:a={}}){if(v.debug("consumeData()"),this._closed)throw new l.InvalidStateError("closed");if("recv"!==this._direction)throw new l.UnsupportedError("not a receiving Transport");if(!this._maxSctpMessageSize)throw new l.UnsupportedError("SCTP not enabled by remote Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing dataProducerId");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(a&&"object"!=typeof a)throw new TypeError("if given, appData must be an object");const s=h.clone(r);return f.validateSctpStreamParameters(s),this._awaitQueue.push((async()=>{const{dataChannel:r}=await this._handler.receiveDataChannel({sctpStreamParameters:s,label:i,protocol:n}),o=new g.DataConsumer({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:s,appData:a});return this._dataConsumers.set(o.id,o),this.handleDataConsumer(o),this._observer.safeEmit("newdataconsumer",o),o}),"transport.consumeData()")}async createPendingConsumers(){this._consumerCreationInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingConsumerTasks.length)return void v.debug("createPendingConsumers() | there is no Consumer to be created");const e=[...this._pendingConsumerTasks];let t;this._pendingConsumerTasks=[];const r=[];for(const t of e){const{id:e,kind:i,rtpParameters:n,streamId:a,onRtpReceiver:s}=t.consumerOptions;r.push({trackId:e,kind:i,rtpParameters:n,streamId:a,onRtpReceiver:s})}try{const i=await this._handler.receive(r);for(let r=0;r<i.length;++r){const n=e[r],a=i[r],{id:s,producerId:o,kind:c,rtpParameters:d,appData:u}=n.consumerOptions,{localId:l,rtpReceiver:h,track:f}=a,p=new m.Consumer({id:s,localId:l,producerId:o,rtpReceiver:h,track:f,rtpParameters:d,appData:u});this._consumers.set(p.id,p),this.handleConsumer(p),this._probatorConsumerCreated||t||"video"!==c||(t=p),this._observer.safeEmit("newconsumer",p),n.resolve(p)}}catch(t){for(const r of e)r.reject(t)}if(t)try{const e=f.generateProbatorRtpParameters(t.rtpParameters);await this._handler.receive([{trackId:"probator",kind:"video",rtpParameters:e}]),v.debug("createPendingConsumers() | Consumer for RTP probation created"),this._probatorConsumerCreated=!0}catch(e){v.error("createPendingConsumers() | failed to create Consumer for RTP probation:%o",e)}}),"transport.createPendingConsumers()").then((()=>{this._consumerCreationInProgress=!1,this._pendingConsumerTasks.length>0&&this.createPendingConsumers()})).catch((()=>{}))}pausePendingConsumers(){this._consumerPauseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingPauseConsumers.size)return void v.debug("pausePendingConsumers() | there is no Consumer to be paused");const e=Array.from(this._pendingPauseConsumers.values());this._pendingPauseConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.pauseReceiving(t)}catch(e){v.error("pausePendingConsumers() | failed to pause Consumers:",e)}}),"transport.pausePendingConsumers").then((()=>{this._consumerPauseInProgress=!1,this._pendingPauseConsumers.size>0&&this.pausePendingConsumers()})).catch((()=>{}))}resumePendingConsumers(){this._consumerResumeInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingResumeConsumers.size)return void v.debug("resumePendingConsumers() | there is no Consumer to be resumed");const e=Array.from(this._pendingResumeConsumers.values());this._pendingResumeConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.resumeReceiving(t)}catch(e){v.error("resumePendingConsumers() | failed to resume Consumers:",e)}}),"transport.resumePendingConsumers").then((()=>{this._consumerResumeInProgress=!1,this._pendingResumeConsumers.size>0&&this.resumePendingConsumers()})).catch((()=>{}))}closePendingConsumers(){this._consumerCloseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingCloseConsumers.size)return void v.debug("closePendingConsumers() | there is no Consumer to be closed");const e=Array.from(this._pendingCloseConsumers.values());this._pendingCloseConsumers.clear();try{await this._handler.stopReceiving(e.map((e=>e.localId)))}catch(e){v.error("closePendingConsumers() | failed to close Consumers:",e)}}),"transport.closePendingConsumers").then((()=>{this._consumerCloseInProgress=!1,this._pendingCloseConsumers.size>0&&this.closePendingConsumers()})).catch((()=>{}))}handleHandler(){const e=this._handler;e.on("@connect",(({dtlsParameters:e},t,r)=>{this._closed?r(new l.InvalidStateError("closed")):this.safeEmit("connect",{dtlsParameters:e},t,r)})),e.on("@icegatheringstatechange",(e=>{e!==this._iceGatheringState&&(v.debug("ICE gathering state changed to %s",e),this._iceGatheringState=e,this._closed||this.safeEmit("icegatheringstatechange",e))})),e.on("@connectionstatechange",(e=>{e!==this._connectionState&&(v.debug("connection state changed to %s",e),this._connectionState=e,this._closed||this.safeEmit("connectionstatechange",e))}))}handleProducer(e){e.on("@close",(()=>{this._producers.delete(e.id),this._closed||this._awaitQueue.push((async()=>await this._handler.stopSending(e.localId)),"producer @close event").catch((e=>v.warn("producer.close() failed:%o",e)))})),e.on("@pause",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.pauseSending(e.localId)),"producer @pause event").then(t).catch(r)})),e.on("@resume",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.resumeSending(e.localId)),"producer @resume event").then(t).catch(r)})),e.on("@replacetrack",((t,r,i)=>{this._awaitQueue.push((async()=>await this._handler.replaceTrack(e.localId,t)),"producer @replacetrack event").then(r).catch(i)})),e.on("@setmaxspatiallayer",((t,r,i)=>{this._awaitQueue.push((async()=>await this._handler.setMaxSpatialLayer(e.localId,t)),"producer @setmaxspatiallayer event").then(r).catch(i)})),e.on("@setrtpencodingparameters",((t,r,i)=>{this._awaitQueue.push((async()=>await this._handler.setRtpEncodingParameters(e.localId,t)),"producer @setrtpencodingparameters event").then(r).catch(i)})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new l.InvalidStateError("closed"));this._handler.getSenderStats(e.localId).then(t).catch(r)}))}handleConsumer(e){e.on("@close",(()=>{this._consumers.delete(e.id),this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.delete(e.id),this._closed||(this._pendingCloseConsumers.set(e.id,e),!1===this._consumerCloseInProgress&&this.closePendingConsumers())})),e.on("@pause",(()=>{this._pendingResumeConsumers.has(e.id)&&this._pendingResumeConsumers.delete(e.id),this._pendingPauseConsumers.set(e.id,e),(0,c.default)((()=>{this._closed||!1===this._consumerPauseInProgress&&this.pausePendingConsumers()}))})),e.on("@resume",(()=>{this._pendingPauseConsumers.has(e.id)&&this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.set(e.id,e),(0,c.default)((()=>{this._closed||!1===this._consumerResumeInProgress&&this.resumePendingConsumers()}))})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new l.InvalidStateError("closed"));this._handler.getReceiverStats(e.localId).then(t).catch(r)}))}handleDataProducer(e){e.on("@close",(()=>{this._dataProducers.delete(e.id)}))}handleDataConsumer(e){e.on("@close",(()=>{this._dataConsumers.delete(e.id)}))}}r.Transport=_},{"./Consumer":201,"./DataConsumer":202,"./DataProducer":203,"./EnhancedEventEmitter":205,"./Logger":206,"./Producer":207,"./errors":211,"./ortc":233,"./utils":236,awaitqueue:57,"queue-microtask":265}],211:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidStateError=r.UnsupportedError=void 0;class i extends Error{constructor(e){super(e),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,i):this.stack=new Error(e).stack}}r.UnsupportedError=i;class n extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,n):this.stack=new Error(e).stack}}r.InvalidStateError=n},{}],212:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Chrome111=void 0;const s=a(e("sdp-transform")),o=e("../Logger"),c=a(e("../utils")),d=a(e("../ortc")),u=a(e("./sdp/commonUtils")),l=a(e("./sdp/unifiedPlanUtils")),h=a(e("./ortc/utils")),f=e("../errors"),p=e("./HandlerInterface"),m=e("./sdp/RemoteSdp"),b=e("../scalabilityModes"),g=new o.Logger("Chrome111"),v={OS:1024,MIS:1024};class y extends p.HandlerInterface{static createFactory(){return()=>new y}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome111"}close(){if(g.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){g.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=s.parse(t.sdp),i=u.extractRtpCapabilities({sdpObject:r});return h.addNackSuppportForOpus(i),i}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return g.debug("getNativeSctpCapabilities()"),{numStreams:v}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,extendedRtpCapabilities:u}){this.assertNotClosed(),g.debug("run()"),this._direction=e,this._remoteSdp=new m.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n}),this._sendingRtpParametersByKind={audio:d.getSendingRtpParameters("audio",u),video:d.getSendingRtpParameters("video",u)},this._sendingRemoteRtpParametersByKind={audio:d.getSendingRemoteRtpParameters("audio",u),video:d.getSendingRemoteRtpParameters("video",u)},i.role&&"auto"!==i.role&&(this._forcedLocalDtlsRole="server"===i.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:s||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...o},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):(g.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})))}async updateIceServers(e){this.assertNotClosed(),g.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),g.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});g.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();g.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i,onRtpSender:n}){if(this.assertNotClosed(),this.assertSendDirection(),g.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1){let e=1;for(const r of t){const t=r.scalabilityMode?(0,b.parse)(r.scalabilityMode).temporalLayers:3;t>e&&(e=t)}t.forEach(((t,r)=>{t.rid=`r${r}`,t.scalabilityMode=`L1T${e}`}))}const a=c.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=d.reduceCodecs(a.codecs,i);const o=c.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=d.reduceCodecs(o.codecs,i);const h=this._remoteSdp.getNextMediaSectionIdx(),f=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});n&&n(f.sender);const p=await this._pc.createOffer();let m=s.parse(p.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:m}),g.debug("send() | calling pc.setLocalDescription() [offer:%o]",p),await this._pc.setLocalDescription(p);const v=f.mid;a.mid=v,m=s.parse(this._pc.localDescription.sdp);const y=m.media[h.idx];if(a.rtcp.cname=u.getCname({offerMediaObject:y}),t)if(1===t.length){const e=l.getRtpEncodings({offerMediaObject:y});Object.assign(e[0],t[0]),a.encodings=e}else a.encodings=t;else a.encodings=l.getRtpEncodings({offerMediaObject:y});this._remoteSdp.send({offerMediaObject:y,reuseMid:h.reuseMid,offerRtpParameters:a,answerRtpParameters:o,codecOptions:r,extmapAllowMixed:!0});const _={type:"answer",sdp:this._remoteSdp.getSdp()};return g.debug("send() | calling pc.setRemoteDescription() [answer:%o]",_),await this._pc.setRemoteDescription(_),this._mapMidTransceiver.set(v,f),{localId:v,rtpParameters:a,rtpSender:f.sender}}async stopSending(e){if(this.assertSendDirection(),g.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();g.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),g.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();g.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),g.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();g.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?g.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):g.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),g.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();g.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),g.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{i.encodings[r]={...e,...t}})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();g.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n}){this.assertNotClosed(),this.assertSendDirection();const a={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:n};g.debug("sendDataChannel() [options:%o]",a);const o=this._pc.createDataChannel(i,a);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%v.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),g.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:a.id,ordered:a.ordered,maxPacketLifeTime:a.maxPacketLifeTime,maxRetransmits:a.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:i,rtpParameters:n,streamId:a}=t;g.debug("receive() [trackId:%s, kind:%s]",e,i);const s=n.mid||String(this._mapMidTransceiver.size);r.set(e,s),this._remoteSdp.receive({mid:s,kind:i,offerRtpParameters:n,streamId:a||n.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);for(const t of e){const{trackId:e,onRtpReceiver:i}=t;if(i){const t=r.get(e),n=this._pc.getTransceivers().find((e=>e.mid===t));if(!n)throw new Error("transceiver not found");i(n.receiver)}}let n=await this._pc.createAnswer();const a=s.parse(n.sdp);for(const t of e){const{trackId:e,rtpParameters:i}=t,n=r.get(e),s=a.media.find((e=>String(e.mid)===n));u.applyCodecParameters({offerRtpParameters:i,answerMediaObject:s})}n={type:"answer",sdp:s.write(a)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a}),g.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const i of e){const{trackId:e}=i,n=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===n));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(n,a),t.push({localId:n,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){g.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){g.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){g.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o,protocol:r};g.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}g.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=u.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new f.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}r.Chrome111=y},{"../Logger":206,"../errors":211,"../ortc":233,"../scalabilityModes":234,"../utils":236,"./HandlerInterface":220,"./ortc/utils":226,"./sdp/RemoteSdp":228,"./sdp/commonUtils":229,"./sdp/unifiedPlanUtils":231,"sdp-transform":286}],213:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Chrome55=void 0;const s=a(e("sdp-transform")),o=e("../Logger"),c=e("../errors"),d=a(e("../utils")),u=a(e("../ortc")),l=a(e("./sdp/commonUtils")),h=a(e("./sdp/planBUtils")),f=e("./HandlerInterface"),p=e("./sdp/RemoteSdp"),m=new o.Logger("Chrome55"),b={OS:1024,MIS:1024};class g extends f.HandlerInterface{static createFactory(){return()=>new g}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdTrack=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome55"}close(){if(m.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){m.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=s.parse(t.sdp);return l.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return m.debug("getNativeSctpCapabilities()"),{numStreams:b}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,extendedRtpCapabilities:d}){m.debug("run()"),this._direction=e,this._remoteSdp=new p.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,planB:!0}),this._sendingRtpParametersByKind={audio:u.getSendingRtpParameters("audio",d),video:u.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:u.getSendingRemoteRtpParameters("audio",d),video:u.getSendingRemoteRtpParameters("video",d)},i.role&&"auto"!==i.role&&(this._forcedLocalDtlsRole="server"===i.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:s||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...o},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(m.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){m.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(m.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});m.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();m.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertSendDirection(),m.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),i&&m.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addStream(this._sendStream);let n,a=await this._pc.createOffer(),o=s.parse(a.sdp);const c=d.clone(this._sendingRtpParametersByKind[e.kind]);c.codecs=u.reduceCodecs(c.codecs);const f=d.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(f.codecs=u.reduceCodecs(f.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(m.debug("send() | enabling simulcast"),o=s.parse(a.sdp),n=o.media.find((e=>"video"===e.type)),h.addLegacySimulcast({offerMediaObject:n,track:e,numStreams:t.length}),a={type:"offer",sdp:s.write(o)}),m.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a),o=s.parse(this._pc.localDescription.sdp),n=o.media.find((t=>t.type===e.kind)),c.rtcp.cname=l.getCname({offerMediaObject:n}),c.encodings=h.getRtpEncodings({offerMediaObject:n,track:e}),t)for(let e=0;e<c.encodings.length;++e)t[e]&&Object.assign(c.encodings[e],t[e]);if(c.encodings.length>1&&"video/vp8"===c.codecs[0].mimeType.toLowerCase())for(const e of c.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:n,offerRtpParameters:c,answerRtpParameters:f,codecOptions:r});const p={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("send() | calling pc.setRemoteDescription() [answer:%o]",p),await this._pc.setRemoteDescription(p);const b=String(this._nextSendLocalId);return this._nextSendLocalId++,this._mapSendLocalIdTrack.set(b,e),{localId:b,rtpParameters:c}}async stopSending(e){this.assertSendDirection(),m.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdTrack.get(e);if(!t)throw new Error("track not found");this._mapSendLocalIdTrack.delete(e),this._sendStream.removeTrack(t),this._pc.addStream(this._sendStream);const r=await this._pc.createOffer();m.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void m.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const i={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){throw new c.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new c.UnsupportedError(" not implemented")}async setRtpEncodingParameters(e,t){throw new c.UnsupportedError("not supported")}async getSenderStats(e){throw new c.UnsupportedError("not implemented")}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n}){this.assertSendDirection();const a={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:n};m.debug("sendDataChannel() [options:%o]",a);const o=this._pc.createDataChannel(i,a);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%b.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),m.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:a.id,ordered:a.ordered,maxPacketLifeTime:a.maxPacketLifeTime,maxRetransmits:a.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:i,streamId:n}=t;m.debug("receive() [trackId:%s, kind:%s]",e,r);const a=r;this._remoteSdp.receive({mid:a,kind:r,offerRtpParameters:i,streamId:n||i.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let i=await this._pc.createAnswer();const n=s.parse(i.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,i=e,a=n.media.find((e=>String(e.mid)===i));l.applyCodecParameters({offerRtpParameters:r,answerMediaObject:a})}i={type:"answer",sdp:s.write(n)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:n}),m.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const r of e){const{kind:e,trackId:i,rtpParameters:n}=r,a=e,s=i,o=r.streamId||n.rtcp.cname,c=this._pc.getRemoteStreams().find((e=>e.id===o)).getTrackById(s);if(!c)throw new Error("remote track not found");this._mapRecvLocalIdInfo.set(s,{mid:a,rtpParameters:n}),t.push({localId:s,track:c})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){m.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)||{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new c.UnsupportedError("not implemented")}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:n,maxPacketLifeTime:a,maxRetransmitTime:a,maxRetransmits:o,protocol:r};m.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=l.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}r.Chrome55=g},{"../Logger":206,"../errors":211,"../ortc":233,"../utils":236,"./HandlerInterface":220,"./sdp/RemoteSdp":228,"./sdp/commonUtils":229,"./sdp/planBUtils":230,"sdp-transform":286}],214:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Chrome67=void 0;const s=a(e("sdp-transform")),o=e("../Logger"),c=a(e("../utils")),d=a(e("../ortc")),u=a(e("./sdp/commonUtils")),l=a(e("./sdp/planBUtils")),h=e("./HandlerInterface"),f=e("./sdp/RemoteSdp"),p=new o.Logger("Chrome67"),m={OS:1024,MIS:1024};class b extends h.HandlerInterface{static createFactory(){return()=>new b}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdRtpSender=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome67"}close(){if(p.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){p.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=s.parse(t.sdp);return u.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return p.debug("getNativeSctpCapabilities()"),{numStreams:m}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,extendedRtpCapabilities:u}){p.debug("run()"),this._direction=e,this._remoteSdp=new f.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,planB:!0}),this._sendingRtpParametersByKind={audio:d.getSendingRtpParameters("audio",u),video:d.getSendingRtpParameters("video",u)},this._sendingRemoteRtpParametersByKind={audio:d.getSendingRemoteRtpParameters("audio",u),video:d.getSendingRemoteRtpParameters("video",u)},i.role&&"auto"!==i.role&&(this._forcedLocalDtlsRole="server"===i.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:s||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...o},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(p.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){p.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(p.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});p.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};p.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};p.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();p.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertSendDirection(),p.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),i&&p.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addTrack(e,this._sendStream);let n,a=await this._pc.createOffer(),o=s.parse(a.sdp);const h=c.clone(this._sendingRtpParametersByKind[e.kind]);h.codecs=d.reduceCodecs(h.codecs);const f=c.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(f.codecs=d.reduceCodecs(f.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(p.debug("send() | enabling simulcast"),o=s.parse(a.sdp),n=o.media.find((e=>"video"===e.type)),l.addLegacySimulcast({offerMediaObject:n,track:e,numStreams:t.length}),a={type:"offer",sdp:s.write(o)}),p.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a),o=s.parse(this._pc.localDescription.sdp),n=o.media.find((t=>t.type===e.kind)),h.rtcp.cname=u.getCname({offerMediaObject:n}),h.encodings=l.getRtpEncodings({offerMediaObject:n,track:e}),t)for(let e=0;e<h.encodings.length;++e)t[e]&&Object.assign(h.encodings[e],t[e]);if(h.encodings.length>1&&"video/vp8"===h.codecs[0].mimeType.toLowerCase())for(const e of h.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:n,offerRtpParameters:h,answerRtpParameters:f,codecOptions:r});const m={type:"answer",sdp:this._remoteSdp.getSdp()};p.debug("send() | calling pc.setRemoteDescription() [answer:%o]",m),await this._pc.setRemoteDescription(m);const b=String(this._nextSendLocalId);this._nextSendLocalId++;const g=this._pc.getSenders().find((t=>t.track===e));return this._mapSendLocalIdRtpSender.set(b,g),{localId:b,rtpParameters:h,rtpSender:g}}async stopSending(e){this.assertSendDirection(),p.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");this._pc.removeTrack(t),t.track&&this._sendStream.removeTrack(t.track),this._mapSendLocalIdRtpSender.delete(e);const r=await this._pc.createOffer();p.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void p.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const i={type:"answer",sdp:this._remoteSdp.getSdp()};p.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?p.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):p.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const i=r.track;await r.replaceTrack(t),i&&this._sendStream.removeTrack(i),t&&this._sendStream.addTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),p.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const i=r.getParameters();i.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(i)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),p.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const i=r.getParameters();i.encodings.forEach(((e,r)=>{i.encodings[r]={...e,...t}})),await r.setParameters(i)}async getSenderStats(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");return t.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n}){this.assertSendDirection();const a={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:n};p.debug("sendDataChannel() [options:%o]",a);const o=this._pc.createDataChannel(i,a);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%m.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),p.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};p.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:a.id,ordered:a.ordered,maxPacketLifeTime:a.maxPacketLifeTime,maxRetransmits:a.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:i,streamId:n}=t;p.debug("receive() [trackId:%s, kind:%s]",e,r);const a=r;this._remoteSdp.receive({mid:a,kind:r,offerRtpParameters:i,streamId:n||i.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};p.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let i=await this._pc.createAnswer();const n=s.parse(i.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,i=e,a=n.media.find((e=>String(e.mid)===i));u.applyCodecParameters({offerRtpParameters:r,answerMediaObject:a})}i={type:"answer",sdp:s.write(n)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:n}),p.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const r of e){const{kind:e,trackId:i,rtpParameters:n}=r,a=i,s=e,o=this._pc.getReceivers().find((e=>e.track&&e.track.id===a));if(!o)throw new Error("new RTCRtpReceiver not");this._mapRecvLocalIdInfo.set(a,{mid:s,rtpParameters:n,rtpReceiver:o}),t.push({localId:a,track:o.track,rtpReceiver:o})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){p.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)||{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};p.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();p.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){this.assertRecvDirection();const{rtpReceiver:t}=this._mapRecvLocalIdInfo.get(e)||{};if(!t)throw new Error("associated RTCRtpReceiver not found");return t.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:n,maxPacketLifeTime:a,maxRetransmitTime:a,maxRetransmits:o,protocol:r};p.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};p.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}p.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=u.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}r.Chrome67=b},{"../Logger":206,"../ortc":233,"../utils":236,"./HandlerInterface":220,"./sdp/RemoteSdp":228,"./sdp/commonUtils":229,"./sdp/planBUtils":230,"sdp-transform":286}],215:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Chrome70=void 0;const s=a(e("sdp-transform")),o=e("../Logger"),c=a(e("../utils")),d=a(e("../ortc")),u=a(e("./sdp/commonUtils")),l=a(e("./sdp/unifiedPlanUtils")),h=e("./HandlerInterface"),f=e("./sdp/RemoteSdp"),p=e("../scalabilityModes"),m=new o.Logger("Chrome70"),b={OS:1024,MIS:1024};class g extends h.HandlerInterface{static createFactory(){return()=>new g}constructor(){super(),this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome70"}close(){if(m.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){m.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=s.parse(t.sdp);return u.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return m.debug("getNativeSctpCapabilities()"),{numStreams:b}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,extendedRtpCapabilities:u}){m.debug("run()"),this._direction=e,this._remoteSdp=new f.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n}),this._sendingRtpParametersByKind={audio:d.getSendingRtpParameters("audio",u),video:d.getSendingRtpParameters("video",u)},this._sendingRemoteRtpParametersByKind={audio:d.getSendingRemoteRtpParameters("audio",u),video:d.getSendingRemoteRtpParameters("video",u)},i.role&&"auto"!==i.role&&(this._forcedLocalDtlsRole="server"===i.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:s||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...o},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(m.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){m.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(m.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});m.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();m.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertSendDirection(),m.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const n=c.clone(this._sendingRtpParametersByKind[e.kind]);n.codecs=d.reduceCodecs(n.codecs,i);const a=c.clone(this._sendingRemoteRtpParametersByKind[e.kind]);a.codecs=d.reduceCodecs(a.codecs,i);const o=this._remoteSdp.getNextMediaSectionIdx(),h=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});let f,b=await this._pc.createOffer(),g=s.parse(b.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:g}),t&&t.length>1&&(m.debug("send() | enabling legacy simulcast"),g=s.parse(b.sdp),f=g.media[o.idx],l.addLegacySimulcast({offerMediaObject:f,numStreams:t.length}),b={type:"offer",sdp:s.write(g)});let v=!1;const y=(0,p.parse)((t||[{}])[0].scalabilityMode);if(t&&1===t.length&&y.spatialLayers>1&&"video/vp9"===n.codecs[0].mimeType.toLowerCase()&&(m.debug("send() | enabling legacy simulcast for VP9 SVC"),v=!0,g=s.parse(b.sdp),f=g.media[o.idx],l.addLegacySimulcast({offerMediaObject:f,numStreams:y.spatialLayers}),b={type:"offer",sdp:s.write(g)}),m.debug("send() | calling pc.setLocalDescription() [offer:%o]",b),await this._pc.setLocalDescription(b),t){m.debug("send() | applying given encodings");const e=h.sender.getParameters();for(let r=0;r<(e.encodings||[]).length;++r){const i=e.encodings[r],n=t[r];if(!n)break;e.encodings[r]=Object.assign(i,n)}await h.sender.setParameters(e)}const _=h.mid;if(n.mid=_,g=s.parse(this._pc.localDescription.sdp),f=g.media[o.idx],n.rtcp.cname=u.getCname({offerMediaObject:f}),n.encodings=l.getRtpEncodings({offerMediaObject:f}),t)for(let e=0;e<n.encodings.length;++e)t[e]&&Object.assign(n.encodings[e],t[e]);if(v&&(n.encodings=[n.encodings[0]]),n.encodings.length>1&&("video/vp8"===n.codecs[0].mimeType.toLowerCase()||"video/h264"===n.codecs[0].mimeType.toLowerCase()))for(const e of n.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:f,reuseMid:o.reuseMid,offerRtpParameters:n,answerRtpParameters:a,codecOptions:r});const w={type:"answer",sdp:this._remoteSdp.getSdp()};return m.debug("send() | calling pc.setRemoteDescription() [answer:%o]",w),await this._pc.setRemoteDescription(w),this._mapMidTransceiver.set(_,h),{localId:_,rtpParameters:n,rtpSender:h.sender}}async stopSending(e){this.assertSendDirection(),m.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();m.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._mapMidTransceiver.delete(e)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?m.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):m.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),m.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();m.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),m.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{i.encodings[r]={...e,...t}})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();m.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n}){this.assertSendDirection();const a={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:n};m.debug("sendDataChannel() [options:%o]",a);const o=this._pc.createDataChannel(i,a);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%b.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),m.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:a.id,ordered:a.ordered,maxPacketLifeTime:a.maxPacketLifeTime,maxRetransmits:a.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:i,rtpParameters:n,streamId:a}=t;m.debug("receive() [trackId:%s, kind:%s]",e,i);const s=n.mid||String(this._mapMidTransceiver.size);r.set(e,s),this._remoteSdp.receive({mid:s,kind:i,offerRtpParameters:n,streamId:a||n.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);let n=await this._pc.createAnswer();const a=s.parse(n.sdp);for(const t of e){const{trackId:e,rtpParameters:i}=t,n=r.get(e),s=a.media.find((e=>String(e.mid)===n));u.applyCodecParameters({offerRtpParameters:i,answerMediaObject:s})}n={type:"answer",sdp:s.write(a)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a}),m.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const i of e){const{trackId:e}=i,n=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===n));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(n,a),t.push({localId:n,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){m.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:n,maxPacketLifeTime:a,maxRetransmitTime:a,maxRetransmits:o,protocol:r};m.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=u.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}r.Chrome70=g},{"../Logger":206,"../ortc":233,"../scalabilityModes":234,"../utils":236,"./HandlerInterface":220,"./sdp/RemoteSdp":228,"./sdp/commonUtils":229,"./sdp/unifiedPlanUtils":231,"sdp-transform":286}],216:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Chrome74=void 0;const s=a(e("sdp-transform")),o=e("../Logger"),c=a(e("../utils")),d=a(e("../ortc")),u=a(e("./sdp/commonUtils")),l=a(e("./sdp/unifiedPlanUtils")),h=a(e("./ortc/utils")),f=e("../errors"),p=e("./HandlerInterface"),m=e("./sdp/RemoteSdp"),b=e("../scalabilityModes"),g=new o.Logger("Chrome74"),v={OS:1024,MIS:1024};class y extends p.HandlerInterface{static createFactory(){return()=>new y}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome74"}close(){if(g.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){g.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=s.parse(t.sdp),i=u.extractRtpCapabilities({sdpObject:r});return h.addNackSuppportForOpus(i),i}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return g.debug("getNativeSctpCapabilities()"),{numStreams:v}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,extendedRtpCapabilities:u}){g.debug("run()"),this._direction=e,this._remoteSdp=new m.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n}),this._sendingRtpParametersByKind={audio:d.getSendingRtpParameters("audio",u),video:d.getSendingRtpParameters("video",u)},this._sendingRemoteRtpParametersByKind={audio:d.getSendingRemoteRtpParameters("audio",u),video:d.getSendingRemoteRtpParameters("video",u)},i.role&&"auto"!==i.role&&(this._forcedLocalDtlsRole="server"===i.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:s||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...o},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):(g.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})))}async updateIceServers(e){this.assertNotClosed(),g.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),g.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});g.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();g.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertNotClosed(),this.assertSendDirection(),g.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const n=c.clone(this._sendingRtpParametersByKind[e.kind]);n.codecs=d.reduceCodecs(n.codecs,i);const a=c.clone(this._sendingRemoteRtpParametersByKind[e.kind]);a.codecs=d.reduceCodecs(a.codecs,i);const o=this._remoteSdp.getNextMediaSectionIdx(),h=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});let f,p=await this._pc.createOffer(),m=s.parse(p.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:m});let v=!1;const y=(0,b.parse)((t||[{}])[0].scalabilityMode);t&&1===t.length&&y.spatialLayers>1&&"video/vp9"===n.codecs[0].mimeType.toLowerCase()&&(g.debug("send() | enabling legacy simulcast for VP9 SVC"),v=!0,m=s.parse(p.sdp),f=m.media[o.idx],l.addLegacySimulcast({offerMediaObject:f,numStreams:y.spatialLayers}),p={type:"offer",sdp:s.write(m)}),g.debug("send() | calling pc.setLocalDescription() [offer:%o]",p),await this._pc.setLocalDescription(p);const _=h.mid;if(n.mid=_,m=s.parse(this._pc.localDescription.sdp),f=m.media[o.idx],n.rtcp.cname=u.getCname({offerMediaObject:f}),t)if(1===t.length){let e=l.getRtpEncodings({offerMediaObject:f});Object.assign(e[0],t[0]),v&&(e=[e[0]]),n.encodings=e}else n.encodings=t;else n.encodings=l.getRtpEncodings({offerMediaObject:f});if(n.encodings.length>1&&("video/vp8"===n.codecs[0].mimeType.toLowerCase()||"video/h264"===n.codecs[0].mimeType.toLowerCase()))for(const e of n.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${y.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:f,reuseMid:o.reuseMid,offerRtpParameters:n,answerRtpParameters:a,codecOptions:r,extmapAllowMixed:!0});const w={type:"answer",sdp:this._remoteSdp.getSdp()};return g.debug("send() | calling pc.setRemoteDescription() [answer:%o]",w),await this._pc.setRemoteDescription(w),this._mapMidTransceiver.set(_,h),{localId:_,rtpParameters:n,rtpSender:h.sender}}async stopSending(e){if(this.assertSendDirection(),g.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();g.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),g.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();g.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),g.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();g.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?g.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):g.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),g.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();g.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),g.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{i.encodings[r]={...e,...t}})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();g.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n}){this.assertNotClosed(),this.assertSendDirection();const a={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:n};g.debug("sendDataChannel() [options:%o]",a);const o=this._pc.createDataChannel(i,a);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%v.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),g.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:a.id,ordered:a.ordered,maxPacketLifeTime:a.maxPacketLifeTime,maxRetransmits:a.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:i,rtpParameters:n,streamId:a}=t;g.debug("receive() [trackId:%s, kind:%s]",e,i);const s=n.mid||String(this._mapMidTransceiver.size);r.set(e,s),this._remoteSdp.receive({mid:s,kind:i,offerRtpParameters:n,streamId:a||n.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);let n=await this._pc.createAnswer();const a=s.parse(n.sdp);for(const t of e){const{trackId:e,rtpParameters:i}=t,n=r.get(e),s=a.media.find((e=>String(e.mid)===n));u.applyCodecParameters({offerRtpParameters:i,answerMediaObject:s})}n={type:"answer",sdp:s.write(a)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a}),g.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const i of e){const{trackId:e}=i,n=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===n));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(n,a),t.push({localId:n,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){g.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){g.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){g.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o,protocol:r};g.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}g.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=u.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new f.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}r.Chrome74=y},{"../Logger":206,"../errors":211,"../ortc":233,"../scalabilityModes":234,"../utils":236,"./HandlerInterface":220,"./ortc/utils":226,"./sdp/RemoteSdp":228,"./sdp/commonUtils":229,"./sdp/unifiedPlanUtils":231,"sdp-transform":286}],217:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Edge11=void 0;const s=e("../Logger"),o=e("../errors"),c=a(e("../utils")),d=a(e("../ortc")),u=a(e("./ortc/edgeUtils")),l=e("./HandlerInterface"),h=new s.Logger("Edge11");class f extends l.HandlerInterface{static createFactory(){return()=>new f}constructor(){super(),this._rtpSenders=new Map,this._rtpReceivers=new Map,this._nextSendLocalId=0,this._transportReady=!1}get name(){return"Edge11"}close(){h.debug("close()");try{this._iceGatherer.close()}catch(e){}try{this._iceTransport.stop()}catch(e){}try{this._dtlsTransport.stop()}catch(e){}for(const e of this._rtpSenders.values())try{e.stop()}catch(e){}for(const e of this._rtpReceivers.values())try{e.stop()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){return h.debug("getNativeRtpCapabilities()"),u.getCapabilities()}async getNativeSctpCapabilities(){return h.debug("getNativeSctpCapabilities()"),{numStreams:{OS:0,MIS:0}}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:u,extendedRtpCapabilities:l}){h.debug("run()"),this._sendingRtpParametersByKind={audio:d.getSendingRtpParameters("audio",l),video:d.getSendingRtpParameters("video",l)},this._remoteIceParameters=t,this._remoteIceCandidates=r,this._remoteDtlsParameters=i,this._cname=`CNAME-${c.generateRandomNumber()}`,this.setIceGatherer({iceServers:a,iceTransportPolicy:s}),this.setIceTransport(),this.setDtlsTransport()}async updateIceServers(e){throw new o.UnsupportedError("not supported")}async restartIce(e){if(h.debug("restartIce()"),this._remoteIceParameters=e,this._transportReady){h.debug("restartIce() | calling iceTransport.start()"),this._iceTransport.start(this._iceGatherer,e,"controlling");for(const e of this._remoteIceCandidates)this._iceTransport.addRemoteCandidate(e);this._iceTransport.addRemoteCandidate({})}}async getTransportStats(){return this._iceTransport.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){h.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),this._transportReady||await this.setupTransport({localDtlsRole:"server"}),h.debug("send() | calling new RTCRtpSender()");const n=new RTCRtpSender(e,this._dtlsTransport),a=c.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=d.reduceCodecs(a.codecs,i);const s=a.codecs.some((e=>/.+\/rtx$/i.test(e.mimeType)));t||(t=[{}]);for(const e of t)e.ssrc=c.generateRandomNumber(),s&&(e.rtx={ssrc:c.generateRandomNumber()});a.encodings=t,a.rtcp={cname:this._cname,reducedSize:!0,mux:!0};const o=u.mangleRtpParameters(a);h.debug("send() | calling rtpSender.send() [params:%o]",o),await n.send(o);const l=String(this._nextSendLocalId);return this._nextSendLocalId++,this._rtpSenders.set(l,n),{localId:l,rtpParameters:a,rtpSender:n}}async stopSending(e){h.debug("stopSending() [localId:%s]",e);const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");this._rtpSenders.delete(e);try{h.debug("stopSending() | calling rtpSender.stop()"),t.stop()}catch(e){throw h.warn("stopSending() | rtpSender.stop() failed:%o",e),e}}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){t?h.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):h.debug("replaceTrack() [localId:%s, no track]",e);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");r.setTrack(t)}async setMaxSpatialLayer(e,t){h.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");const i=r.getParameters();i.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(i)}async setRtpEncodingParameters(e,t){h.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");const i=r.getParameters();i.encodings.forEach(((e,r)=>{i.encodings[r]={...e,...t}})),await r.setParameters(i)}async getSenderStats(e){const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");return t.getStats()}async sendDataChannel(e){throw new o.UnsupportedError("not implemented")}async receive(e){const t=[];for(const t of e){const{trackId:e,kind:r}=t;h.debug("receive() [trackId:%s, kind:%s]",e,r)}this._transportReady||await this.setupTransport({localDtlsRole:"server"});for(const r of e){const{trackId:e,kind:i,rtpParameters:n}=r;h.debug("receive() | calling new RTCRtpReceiver()");const a=new RTCRtpReceiver(this._dtlsTransport,i);a.addEventListener("error",(e=>{h.error('rtpReceiver "error" event [event:%o]',e)}));const s=u.mangleRtpParameters(n);h.debug("receive() | calling rtpReceiver.receive() [params:%o]",s),await a.receive(s);const o=e;this._rtpReceivers.set(o,a),t.push({localId:o,track:a.track,rtpReceiver:a})}return t}async stopReceiving(e){for(const t of e){h.debug("stopReceiving() [localId:%s]",t);const e=this._rtpReceivers.get(t);if(!e)throw new Error("RTCRtpReceiver not found");this._rtpReceivers.delete(t);try{h.debug("stopReceiving() | calling rtpReceiver.stop()"),e.stop()}catch(e){h.warn("stopReceiving() | rtpReceiver.stop() failed:%o",e)}}}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){const t=this._rtpReceivers.get(e);if(!t)throw new Error("RTCRtpReceiver not found");return t.getStats()}async receiveDataChannel(e){throw new o.UnsupportedError("not implemented")}setIceGatherer({iceServers:e,iceTransportPolicy:t}){const r=new RTCIceGatherer({iceServers:e||[],gatherPolicy:t||"all"});r.addEventListener("error",(e=>{h.error('iceGatherer "error" event [event:%o]',e)}));try{r.gather()}catch(e){h.debug("setIceGatherer() | iceGatherer.gather() failed: %s",e.toString())}this._iceGatherer=r}setIceTransport(){const e=new RTCIceTransport(this._iceGatherer);e.addEventListener("statechange",(()=>{switch(e.state){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})),e.addEventListener("icestatechange",(()=>{switch(e.state){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})),e.addEventListener("candidatepairchange",(e=>{h.debug('iceTransport "candidatepairchange" event [pair:%o]',e.pair)})),this._iceTransport=e}setDtlsTransport(){const e=new RTCDtlsTransport(this._iceTransport);e.addEventListener("statechange",(()=>{h.debug('dtlsTransport "statechange" event [state:%s]',e.state)})),e.addEventListener("dtlsstatechange",(()=>{h.debug('dtlsTransport "dtlsstatechange" event [state:%s]',e.state),"closed"===e.state&&this.emit("@connectionstatechange","closed")})),e.addEventListener("error",(e=>{h.error('dtlsTransport "error" event [event:%o]',e)})),this._dtlsTransport=e}async setupTransport({localDtlsRole:e}){h.debug("setupTransport()");const t=this._dtlsTransport.getLocalParameters();t.role=e,await new Promise(((e,r)=>{this.safeEmit("@connect",{dtlsParameters:t},e,r)})),this._iceTransport.start(this._iceGatherer,this._remoteIceParameters,"controlling");for(const e of this._remoteIceCandidates)this._iceTransport.addRemoteCandidate(e);this._iceTransport.addRemoteCandidate({}),this._remoteDtlsParameters.fingerprints=this._remoteDtlsParameters.fingerprints.filter((e=>"sha-256"===e.algorithm||"sha-384"===e.algorithm||"sha-512"===e.algorithm)),this._dtlsTransport.start(this._remoteDtlsParameters),this._transportReady=!0}}r.Edge11=f},{"../Logger":206,"../errors":211,"../ortc":233,"../utils":236,"./HandlerInterface":220,"./ortc/edgeUtils":225}],218:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Firefox120=void 0;const s=a(e("sdp-transform")),o=e("../Logger"),c=e("../errors"),d=a(e("../utils")),u=a(e("../ortc")),l=a(e("./sdp/commonUtils")),h=a(e("./sdp/unifiedPlanUtils")),f=e("./HandlerInterface"),p=e("./sdp/RemoteSdp"),m=e("../scalabilityModes"),b=new o.Logger("Firefox120"),g={OS:16,MIS:2048};class v extends f.HandlerInterface{static createFactory(){return()=>new v}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Firefox120"}close(){if(b.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){b.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"}),t=document.createElement("canvas");t.getContext("2d");const r=t.captureStream().getVideoTracks()[0];try{e.addTransceiver("audio",{direction:"sendrecv"}),e.addTransceiver(r,{direction:"sendrecv",sendEncodings:[{rid:"r0",maxBitrate:1e5},{rid:"r1",maxBitrate:5e5}]});const i=await e.createOffer();try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}const n=s.parse(i.sdp);return l.extractRtpCapabilities({sdpObject:n})}catch(i){try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}throw i}}async getNativeSctpCapabilities(){return b.debug("getNativeSctpCapabilities()"),{numStreams:g}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),b.debug("run()"),this._direction=e,this._remoteSdp=new p.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n}),this._sendingRtpParametersByKind={audio:u.getSendingRtpParameters("audio",d),video:u.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:u.getSendingRemoteRtpParameters("audio",d),video:u.getSendingRemoteRtpParameters("video",d)},this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:s||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...o},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(b.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){throw this.assertNotClosed(),new c.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),b.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});b.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();b.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i,onRtpSender:n}){this.assertNotClosed(),this.assertSendDirection(),b.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const a=d.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=u.reduceCodecs(a.codecs,i);const o=d.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=u.reduceCodecs(o.codecs,i);const c=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});n&&n(c.sender);const f=await this._pc.createOffer();let p=s.parse(f.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:p});const g=(0,m.parse)((t||[{}])[0].scalabilityMode);b.debug("send() | calling pc.setLocalDescription() [offer:%o]",f),await this._pc.setLocalDescription(f);const v=c.mid;a.mid=v,p=s.parse(this._pc.localDescription.sdp);const y=p.media[p.media.length-1];if(a.rtcp.cname=l.getCname({offerMediaObject:y}),t)if(1===t.length){const e=h.getRtpEncodings({offerMediaObject:y});Object.assign(e[0],t[0]),a.encodings=e}else a.encodings=t;else a.encodings=h.getRtpEncodings({offerMediaObject:y});if(a.encodings.length>1&&("video/vp8"===a.codecs[0].mimeType.toLowerCase()||"video/h264"===a.codecs[0].mimeType.toLowerCase()))for(const e of a.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${g.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:y,offerRtpParameters:a,answerRtpParameters:o,codecOptions:r,extmapAllowMixed:!0});const _={type:"answer",sdp:this._remoteSdp.getSdp()};return b.debug("send() | calling pc.setRemoteDescription() [answer:%o]",_),await this._pc.setRemoteDescription(_),this._mapMidTransceiver.set(v,c),{localId:v,rtpParameters:a,rtpSender:c.sender}}async stopSending(e){if(this.assertSendDirection(),b.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated transceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.disableMediaSection(t.mid);const r=await this._pc.createOffer();b.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),b.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();b.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),b.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();b.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?b.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):b.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),b.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated transceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();b.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),b.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{i.encodings[r]={...e,...t}})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();b.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n}){this.assertNotClosed(),this.assertSendDirection();const a={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:n};b.debug("sendDataChannel() [options:%o]",a);const o=this._pc.createDataChannel(i,a);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%g.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),b.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:a.id,ordered:a.ordered,maxPacketLifeTime:a.maxPacketLifeTime,maxRetransmits:a.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:i,rtpParameters:n,streamId:a}=t;b.debug("receive() [trackId:%s, kind:%s]",e,i);const s=n.mid||String(this._mapMidTransceiver.size);r.set(e,s),this._remoteSdp.receive({mid:s,kind:i,offerRtpParameters:n,streamId:a||n.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);for(const t of e){const{trackId:e,onRtpReceiver:i}=t;if(i){const t=r.get(e),n=this._pc.getTransceivers().find((e=>e.mid===t));if(!n)throw new Error("transceiver not found");i(n.receiver)}}let n=await this._pc.createAnswer();const a=s.parse(n.sdp);for(const t of e){const{trackId:e,rtpParameters:i}=t,o=r.get(e),c=a.media.find((e=>String(e.mid)===o));l.applyCodecParameters({offerRtpParameters:i,answerMediaObject:c}),n={type:"answer",sdp:s.write(a)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:a}),b.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const i of e){const{trackId:e}=i,n=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===n));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(n,a),t.push({localId:n,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){b.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();b.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){b.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();b.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){b.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();b.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o,protocol:r};b.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}b.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=l.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new c.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}r.Firefox120=v},{"../Logger":206,"../errors":211,"../ortc":233,"../scalabilityModes":234,"../utils":236,"./HandlerInterface":220,"./sdp/RemoteSdp":228,"./sdp/commonUtils":229,"./sdp/unifiedPlanUtils":231,"sdp-transform":286}],219:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Firefox60=void 0;const s=a(e("sdp-transform")),o=e("../Logger"),c=e("../errors"),d=a(e("../utils")),u=a(e("../ortc")),l=a(e("./sdp/commonUtils")),h=a(e("./sdp/unifiedPlanUtils")),f=e("./HandlerInterface"),p=e("./sdp/RemoteSdp"),m=e("../scalabilityModes"),b=new o.Logger("Firefox60"),g={OS:16,MIS:2048};class v extends f.HandlerInterface{static createFactory(){return()=>new v}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Firefox60"}close(){if(b.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){b.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"}),t=document.createElement("canvas");t.getContext("2d");const r=t.captureStream().getVideoTracks()[0];try{e.addTransceiver("audio",{direction:"sendrecv"});const i=e.addTransceiver(r,{direction:"sendrecv"}),n=i.sender.getParameters(),a=[{rid:"r0",maxBitrate:1e5},{rid:"r1",maxBitrate:5e5}];n.encodings=a,await i.sender.setParameters(n);const o=await e.createOffer();try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}const c=s.parse(o.sdp);return l.extractRtpCapabilities({sdpObject:c})}catch(i){try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}throw i}}async getNativeSctpCapabilities(){return b.debug("getNativeSctpCapabilities()"),{numStreams:g}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),b.debug("run()"),this._direction=e,this._remoteSdp=new p.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n}),this._sendingRtpParametersByKind={audio:u.getSendingRtpParameters("audio",d),video:u.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:u.getSendingRemoteRtpParameters("audio",d),video:u.getSendingRemoteRtpParameters("video",d)},this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:s||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...o},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(b.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){throw this.assertNotClosed(),new c.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),b.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});b.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();b.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertNotClosed(),this.assertSendDirection(),b.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&(t=d.clone(t)).length>1&&(t.forEach(((e,t)=>{e.rid=`r${t}`})),t.reverse());const n=d.clone(this._sendingRtpParametersByKind[e.kind]);n.codecs=u.reduceCodecs(n.codecs,i);const a=d.clone(this._sendingRemoteRtpParametersByKind[e.kind]);a.codecs=u.reduceCodecs(a.codecs,i);const o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});if(t){const e=o.sender.getParameters();e.encodings=t,await o.sender.setParameters(e)}const c=await this._pc.createOffer();let f=s.parse(c.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:f});const p=(0,m.parse)((t||[{}])[0].scalabilityMode);b.debug("send() | calling pc.setLocalDescription() [offer:%o]",c),await this._pc.setLocalDescription(c);const g=o.mid;n.mid=g,f=s.parse(this._pc.localDescription.sdp);const v=f.media[f.media.length-1];if(n.rtcp.cname=l.getCname({offerMediaObject:v}),t)if(1===t.length){const e=h.getRtpEncodings({offerMediaObject:v});Object.assign(e[0],t[0]),n.encodings=e}else n.encodings=t.reverse();else n.encodings=h.getRtpEncodings({offerMediaObject:v});if(n.encodings.length>1&&("video/vp8"===n.codecs[0].mimeType.toLowerCase()||"video/h264"===n.codecs[0].mimeType.toLowerCase()))for(const e of n.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${p.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:v,offerRtpParameters:n,answerRtpParameters:a,codecOptions:r,extmapAllowMixed:!0});const y={type:"answer",sdp:this._remoteSdp.getSdp()};return b.debug("send() | calling pc.setRemoteDescription() [answer:%o]",y),await this._pc.setRemoteDescription(y),this._mapMidTransceiver.set(g,o),{localId:g,rtpParameters:n,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),b.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated transceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.disableMediaSection(t.mid);const r=await this._pc.createOffer();b.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),b.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();b.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),b.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();b.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?b.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):b.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),b.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated transceiver not found");const i=r.sender.getParameters();t=i.encodings.length-1-t,i.encodings.forEach(((e,r)=>{e.active=r>=t})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();b.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),b.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{i.encodings[r]={...e,...t}})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();b.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n}){this.assertNotClosed(),this.assertSendDirection();const a={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:n};b.debug("sendDataChannel() [options:%o]",a);const o=this._pc.createDataChannel(i,a);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%g.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),b.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};b.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:a.id,ordered:a.ordered,maxPacketLifeTime:a.maxPacketLifeTime,maxRetransmits:a.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:i,rtpParameters:n,streamId:a}=t;b.debug("receive() [trackId:%s, kind:%s]",e,i);const s=n.mid||String(this._mapMidTransceiver.size);r.set(e,s),this._remoteSdp.receive({mid:s,kind:i,offerRtpParameters:n,streamId:a||n.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);let n=await this._pc.createAnswer();const a=s.parse(n.sdp);for(const t of e){const{trackId:e,rtpParameters:i}=t,o=r.get(e),c=a.media.find((e=>String(e.mid)===o));l.applyCodecParameters({offerRtpParameters:i,answerMediaObject:c}),n={type:"answer",sdp:s.write(a)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:a}),b.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const i of e){const{trackId:e}=i,n=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===n));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(n,a),t.push({localId:n,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){b.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();b.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){b.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();b.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){b.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();b.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o,protocol:r};b.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};b.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}b.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=l.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new c.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}r.Firefox60=v},{"../Logger":206,"../errors":211,"../ortc":233,"../scalabilityModes":234,"../utils":236,"./HandlerInterface":220,"./sdp/RemoteSdp":228,"./sdp/commonUtils":229,"./sdp/unifiedPlanUtils":231,"sdp-transform":286}],220:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.HandlerInterface=void 0;const i=e("../EnhancedEventEmitter");class n extends i.EnhancedEventEmitter{constructor(){super()}}r.HandlerInterface=n},{"../EnhancedEventEmitter":205}],221:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.ReactNative=void 0;const s=a(e("sdp-transform")),o=e("../Logger"),c=e("../errors"),d=a(e("../utils")),u=a(e("../ortc")),l=a(e("./sdp/commonUtils")),h=a(e("./sdp/planBUtils")),f=e("./HandlerInterface"),p=e("./sdp/RemoteSdp"),m=new o.Logger("ReactNative"),b={OS:1024,MIS:1024};class g extends f.HandlerInterface{static createFactory(){return()=>new g}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdTrack=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"ReactNative"}close(){if(m.debug("close()"),this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){m.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=s.parse(t.sdp);return l.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return m.debug("getNativeSctpCapabilities()"),{numStreams:b}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,extendedRtpCapabilities:d}){m.debug("run()"),this._direction=e,this._remoteSdp=new p.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,planB:!0}),this._sendingRtpParametersByKind={audio:u.getSendingRtpParameters("audio",d),video:u.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:u.getSendingRemoteRtpParameters("audio",d),video:u.getSendingRemoteRtpParameters("video",d)},i.role&&"auto"!==i.role&&(this._forcedLocalDtlsRole="server"===i.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:s||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...o},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(m.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){m.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(m.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});m.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();m.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertSendDirection(),m.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),i&&m.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addStream(this._sendStream);let n,a=await this._pc.createOffer(),o=s.parse(a.sdp);const c=d.clone(this._sendingRtpParametersByKind[e.kind]);c.codecs=u.reduceCodecs(c.codecs);const f=d.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(f.codecs=u.reduceCodecs(f.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(m.debug("send() | enabling simulcast"),o=s.parse(a.sdp),n=o.media.find((e=>"video"===e.type)),h.addLegacySimulcast({offerMediaObject:n,track:e,numStreams:t.length}),a={type:"offer",sdp:s.write(o)}),m.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a),o=s.parse(this._pc.localDescription.sdp),n=o.media.find((t=>t.type===e.kind)),c.rtcp.cname=l.getCname({offerMediaObject:n}),c.encodings=h.getRtpEncodings({offerMediaObject:n,track:e}),t)for(let e=0;e<c.encodings.length;++e)t[e]&&Object.assign(c.encodings[e],t[e]);if(c.encodings.length>1&&("video/vp8"===c.codecs[0].mimeType.toLowerCase()||"video/h264"===c.codecs[0].mimeType.toLowerCase()))for(const e of c.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:n,offerRtpParameters:c,answerRtpParameters:f,codecOptions:r});const p={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("send() | calling pc.setRemoteDescription() [answer:%o]",p),await this._pc.setRemoteDescription(p);const b=String(this._nextSendLocalId);return this._nextSendLocalId++,this._mapSendLocalIdTrack.set(b,e),{localId:b,rtpParameters:c}}async stopSending(e){this.assertSendDirection(),m.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdTrack.get(e);if(!t)throw new Error("track not found");this._mapSendLocalIdTrack.delete(e),this._sendStream.removeTrack(t),this._pc.addStream(this._sendStream);const r=await this._pc.createOffer();m.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void m.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const i={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){throw new c.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new c.UnsupportedError("not implemented")}async setRtpEncodingParameters(e,t){throw new c.UnsupportedError("not implemented")}async getSenderStats(e){throw new c.UnsupportedError("not implemented")}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n}){this.assertSendDirection();const a={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:n};m.debug("sendDataChannel() [options:%o]",a);const o=this._pc.createDataChannel(i,a);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%b.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),m.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};m.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:a.id,ordered:a.ordered,maxPacketLifeTime:a.maxPacketLifeTime,maxRetransmits:a.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:i,rtpParameters:n}=t;m.debug("receive() [trackId:%s, kind:%s]",e,i);const a=i;let s=t.streamId||n.rtcp.cname;m.debug("receive() | forcing a random remote streamId to avoid well known bug in react-native-webrtc"),s+=`-hack-${d.generateRandomNumber()}`,r.set(e,s),this._remoteSdp.receive({mid:a,kind:i,offerRtpParameters:n,streamId:s,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);let n=await this._pc.createAnswer();const a=s.parse(n.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,i=e,n=a.media.find((e=>String(e.mid)===i));l.applyCodecParameters({offerRtpParameters:r,answerMediaObject:n})}n={type:"answer",sdp:s.write(a)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a}),m.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const i of e){const{kind:e,trackId:n,rtpParameters:a}=i,s=n,o=e,c=r.get(n),d=this._pc.getRemoteStreams().find((e=>e.id===c)).getTrackById(s);if(!d)throw new Error("remote track not found");this._mapRecvLocalIdInfo.set(s,{mid:o,rtpParameters:a}),t.push({localId:s,track:d})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){m.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)||{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();m.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new c.UnsupportedError("not implemented")}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:n,maxPacketLifeTime:a,maxRetransmitTime:a,maxRetransmits:o,protocol:r};m.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}m.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=l.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}r.ReactNative=g},{"../Logger":206,"../errors":211,"../ortc":233,"../utils":236,"./HandlerInterface":220,"./sdp/RemoteSdp":228,"./sdp/commonUtils":229,"./sdp/planBUtils":230,"sdp-transform":286}],222:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.ReactNativeUnifiedPlan=void 0;const s=a(e("sdp-transform")),o=e("../Logger"),c=a(e("../utils")),d=a(e("../ortc")),u=a(e("./sdp/commonUtils")),l=a(e("./sdp/unifiedPlanUtils")),h=a(e("./ortc/utils")),f=e("../errors"),p=e("./HandlerInterface"),m=e("./sdp/RemoteSdp"),b=e("../scalabilityModes"),g=new o.Logger("ReactNativeUnifiedPlan"),v={OS:1024,MIS:1024};class y extends p.HandlerInterface{static createFactory(){return()=>new y}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"ReactNativeUnifiedPlan"}close(){if(g.debug("close()"),!this._closed){if(this._closed=!0,this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){g.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=s.parse(t.sdp),i=u.extractRtpCapabilities({sdpObject:r});return h.addNackSuppportForOpus(i),i}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return g.debug("getNativeSctpCapabilities()"),{numStreams:v}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,extendedRtpCapabilities:u}){this.assertNotClosed(),g.debug("run()"),this._direction=e,this._remoteSdp=new m.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n}),this._sendingRtpParametersByKind={audio:d.getSendingRtpParameters("audio",u),video:d.getSendingRtpParameters("video",u)},this._sendingRemoteRtpParametersByKind={audio:d.getSendingRemoteRtpParameters("audio",u),video:d.getSendingRemoteRtpParameters("video",u)},i.role&&"auto"!==i.role&&(this._forcedLocalDtlsRole="server"===i.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:s||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...o},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(g.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){this.assertNotClosed(),g.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),g.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});g.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();g.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i,onRtpSender:n}){this.assertNotClosed(),this.assertSendDirection(),g.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const a=c.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=d.reduceCodecs(a.codecs,i);const o=c.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=d.reduceCodecs(o.codecs,i);const h=this._remoteSdp.getNextMediaSectionIdx(),f=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});n&&n(f.sender);let p,m=await this._pc.createOffer(),v=s.parse(m.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:v});let y=!1;const _=(0,b.parse)((t||[{}])[0].scalabilityMode);t&&1===t.length&&_.spatialLayers>1&&"video/vp9"===a.codecs[0].mimeType.toLowerCase()&&(g.debug("send() | enabling legacy simulcast for VP9 SVC"),y=!0,v=s.parse(m.sdp),p=v.media[h.idx],l.addLegacySimulcast({offerMediaObject:p,numStreams:_.spatialLayers}),m={type:"offer",sdp:s.write(v)}),g.debug("send() | calling pc.setLocalDescription() [offer:%o]",m),await this._pc.setLocalDescription(m);let w=f.mid??void 0;if(w||g.warn("send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround"),a.mid=w,v=s.parse(this._pc.localDescription.sdp),p=v.media[h.idx],a.rtcp.cname=u.getCname({offerMediaObject:p}),t)if(1===t.length){let e=l.getRtpEncodings({offerMediaObject:p});Object.assign(e[0],t[0]),y&&(e=[e[0]]),a.encodings=e}else a.encodings=t;else a.encodings=l.getRtpEncodings({offerMediaObject:p});if(a.encodings.length>1&&("video/vp8"===a.codecs[0].mimeType.toLowerCase()||"video/h264"===a.codecs[0].mimeType.toLowerCase()))for(const e of a.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${_.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:p,reuseMid:h.reuseMid,offerRtpParameters:a,answerRtpParameters:o,codecOptions:r,extmapAllowMixed:!0});const S={type:"answer",sdp:this._remoteSdp.getSdp()};return g.debug("send() | calling pc.setRemoteDescription() [answer:%o]",S),await this._pc.setRemoteDescription(S),w||(w=f.mid,a.mid=w),this._mapMidTransceiver.set(w,f),{localId:w,rtpParameters:a,rtpSender:f.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;g.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();g.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),g.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();g.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),g.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();g.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?g.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):g.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),g.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();g.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),g.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{i.encodings[r]={...e,...t}})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();g.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n}){this.assertNotClosed(),this.assertSendDirection();const a={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:n};g.debug("sendDataChannel() [options:%o]",a);const o=this._pc.createDataChannel(i,a);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%v.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),g.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:a.id,ordered:a.ordered,maxPacketLifeTime:a.maxPacketLifeTime,maxRetransmits:a.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:i,rtpParameters:n,streamId:a}=t;g.debug("receive() [trackId:%s, kind:%s]",e,i);const s=n.mid||String(this._mapMidTransceiver.size);r.set(e,s),this._remoteSdp.receive({mid:s,kind:i,offerRtpParameters:n,streamId:a||n.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);for(const t of e){const{trackId:e,onRtpReceiver:i}=t;if(i){const t=r.get(e),n=this._pc.getTransceivers().find((e=>e.mid===t));if(!n)throw new Error("transceiver not found");i(n.receiver)}}let n=await this._pc.createAnswer();const a=s.parse(n.sdp);for(const t of e){const{trackId:e,rtpParameters:i}=t,n=r.get(e),s=a.media.find((e=>String(e.mid)===n));u.applyCodecParameters({offerRtpParameters:i,answerMediaObject:s})}n={type:"answer",sdp:s.write(a)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a}),g.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const i of e){const{trackId:e}=i,n=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===n));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(n,a),t.push({localId:n,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){g.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){g.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){g.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o,protocol:r};g.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}g.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=u.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new f.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}r.ReactNativeUnifiedPlan=y},{"../Logger":206,"../errors":211,"../ortc":233,"../scalabilityModes":234,"../utils":236,"./HandlerInterface":220,"./ortc/utils":226,"./sdp/RemoteSdp":228,"./sdp/commonUtils":229,"./sdp/unifiedPlanUtils":231,"sdp-transform":286}],223:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Safari11=void 0;const s=a(e("sdp-transform")),o=e("../Logger"),c=a(e("../utils")),d=a(e("../ortc")),u=a(e("./sdp/commonUtils")),l=a(e("./sdp/planBUtils")),h=e("./HandlerInterface"),f=e("./sdp/RemoteSdp"),p=new o.Logger("Safari11"),m={OS:1024,MIS:1024};class b extends h.HandlerInterface{static createFactory(){return()=>new b}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdRtpSender=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Safari11"}close(){if(p.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){p.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=s.parse(t.sdp);return u.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return p.debug("getNativeSctpCapabilities()"),{numStreams:m}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,extendedRtpCapabilities:u}){p.debug("run()"),this._direction=e,this._remoteSdp=new f.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,planB:!0}),this._sendingRtpParametersByKind={audio:d.getSendingRtpParameters("audio",u),video:d.getSendingRtpParameters("video",u)},this._sendingRemoteRtpParametersByKind={audio:d.getSendingRemoteRtpParameters("audio",u),video:d.getSendingRemoteRtpParameters("video",u)},i.role&&"auto"!==i.role&&(this._forcedLocalDtlsRole="server"===i.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:s||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...o},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(p.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){p.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(p.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});p.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};p.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};p.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();p.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i}){this.assertSendDirection(),p.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),i&&p.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addTrack(e,this._sendStream);let n,a=await this._pc.createOffer(),o=s.parse(a.sdp);const h=c.clone(this._sendingRtpParametersByKind[e.kind]);h.codecs=d.reduceCodecs(h.codecs);const f=c.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(f.codecs=d.reduceCodecs(f.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(p.debug("send() | enabling simulcast"),o=s.parse(a.sdp),n=o.media.find((e=>"video"===e.type)),l.addLegacySimulcast({offerMediaObject:n,track:e,numStreams:t.length}),a={type:"offer",sdp:s.write(o)}),p.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a),o=s.parse(this._pc.localDescription.sdp),n=o.media.find((t=>t.type===e.kind)),h.rtcp.cname=u.getCname({offerMediaObject:n}),h.encodings=l.getRtpEncodings({offerMediaObject:n,track:e}),t)for(let e=0;e<h.encodings.length;++e)t[e]&&Object.assign(h.encodings[e],t[e]);if(h.encodings.length>1&&"video/vp8"===h.codecs[0].mimeType.toLowerCase())for(const e of h.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:n,offerRtpParameters:h,answerRtpParameters:f,codecOptions:r});const m={type:"answer",sdp:this._remoteSdp.getSdp()};p.debug("send() | calling pc.setRemoteDescription() [answer:%o]",m),await this._pc.setRemoteDescription(m);const b=String(this._nextSendLocalId);this._nextSendLocalId++;const g=this._pc.getSenders().find((t=>t.track===e));return this._mapSendLocalIdRtpSender.set(b,g),{localId:b,rtpParameters:h,rtpSender:g}}async stopSending(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");t.track&&this._sendStream.removeTrack(t.track),this._mapSendLocalIdRtpSender.delete(e);const r=await this._pc.createOffer();p.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void p.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const i={type:"answer",sdp:this._remoteSdp.getSdp()};p.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?p.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):p.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const i=r.track;await r.replaceTrack(t),i&&this._sendStream.removeTrack(i),t&&this._sendStream.addTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),p.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const i=r.getParameters();i.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(i)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),p.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const i=r.getParameters();i.encodings.forEach(((e,r)=>{i.encodings[r]={...e,...t}})),await r.setParameters(i)}async getSenderStats(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");return t.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n}){this.assertSendDirection();const a={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:n};p.debug("sendDataChannel() [options:%o]",a);const o=this._pc.createDataChannel(i,a);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%m.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),p.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};p.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:a.id,ordered:a.ordered,maxPacketLifeTime:a.maxPacketLifeTime,maxRetransmits:a.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:i,streamId:n}=t;p.debug("receive() [trackId:%s, kind:%s]",e,r);const a=r;this._remoteSdp.receive({mid:a,kind:r,offerRtpParameters:i,streamId:n||i.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};p.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let i=await this._pc.createAnswer();const n=s.parse(i.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,i=e,a=n.media.find((e=>String(e.mid)===i));u.applyCodecParameters({offerRtpParameters:r,answerMediaObject:a})}i={type:"answer",sdp:s.write(n)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:n}),p.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const r of e){const{kind:e,trackId:i,rtpParameters:n}=r,a=e,s=i,o=this._pc.getReceivers().find((e=>e.track&&e.track.id===s));if(!o)throw new Error("new RTCRtpReceiver not");this._mapRecvLocalIdInfo.set(s,{mid:a,rtpParameters:n,rtpReceiver:o}),t.push({localId:s,track:o.track,rtpReceiver:o})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){p.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)||{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};p.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();p.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const{rtpReceiver:t}=this._mapRecvLocalIdInfo.get(e)||{};if(!t)throw new Error("associated RTCRtpReceiver not found");return t.getStats()}async pauseReceiving(e){}async resumeReceiving(e){}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o,protocol:r};p.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};p.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}p.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=u.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}r.Safari11=b},{"../Logger":206,"../ortc":233,"../utils":236,"./HandlerInterface":220,"./sdp/RemoteSdp":228,"./sdp/commonUtils":229,"./sdp/planBUtils":230,"sdp-transform":286}],224:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Safari12=void 0;const s=a(e("sdp-transform")),o=e("../Logger"),c=a(e("../utils")),d=a(e("../ortc")),u=a(e("./sdp/commonUtils")),l=a(e("./sdp/unifiedPlanUtils")),h=a(e("./ortc/utils")),f=e("../errors"),p=e("./HandlerInterface"),m=e("./sdp/RemoteSdp"),b=e("../scalabilityModes"),g=new o.Logger("Safari12"),v={OS:1024,MIS:1024};class y extends p.HandlerInterface{static createFactory(){return()=>new y}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Safari12"}close(){if(g.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){g.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=s.parse(t.sdp),i=u.extractRtpCapabilities({sdpObject:r});return h.addNackSuppportForOpus(i),i}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return g.debug("getNativeSctpCapabilities()"),{numStreams:v}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n,iceServers:a,iceTransportPolicy:s,additionalSettings:o,proprietaryConstraints:c,extendedRtpCapabilities:u}){this.assertNotClosed(),g.debug("run()"),this._direction=e,this._remoteSdp=new m.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:i,sctpParameters:n}),this._sendingRtpParametersByKind={audio:d.getSendingRtpParameters("audio",u),video:d.getSendingRtpParameters("video",u)},this._sendingRemoteRtpParametersByKind={audio:d.getSendingRemoteRtpParameters("audio",u),video:d.getSendingRemoteRtpParameters("video",u)},i.role&&"auto"!==i.role&&(this._forcedLocalDtlsRole="server"===i.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:a||[],iceTransportPolicy:s||"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...o},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(g.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){this.assertNotClosed(),g.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),g.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});g.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();g.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:i,onRtpSender:n}){this.assertNotClosed(),this.assertSendDirection(),g.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const a=c.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=d.reduceCodecs(a.codecs,i);const o=c.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=d.reduceCodecs(o.codecs,i);const h=this._remoteSdp.getNextMediaSectionIdx(),f=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});n&&n(f.sender);let p,m=await this._pc.createOffer(),v=s.parse(m.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:v});const y=(0,b.parse)((t||[{}])[0].scalabilityMode);t&&t.length>1&&(g.debug("send() | enabling legacy simulcast"),v=s.parse(m.sdp),p=v.media[h.idx],l.addLegacySimulcast({offerMediaObject:p,numStreams:t.length}),m={type:"offer",sdp:s.write(v)}),g.debug("send() | calling pc.setLocalDescription() [offer:%o]",m),await this._pc.setLocalDescription(m);const _=f.mid;if(a.mid=_,v=s.parse(this._pc.localDescription.sdp),p=v.media[h.idx],a.rtcp.cname=u.getCname({offerMediaObject:p}),a.encodings=l.getRtpEncodings({offerMediaObject:p}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&("video/vp8"===a.codecs[0].mimeType.toLowerCase()||"video/h264"===a.codecs[0].mimeType.toLowerCase()))for(const e of a.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${y.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:p,reuseMid:h.reuseMid,offerRtpParameters:a,answerRtpParameters:o,codecOptions:r});const w={type:"answer",sdp:this._remoteSdp.getSdp()};return g.debug("send() | calling pc.setRemoteDescription() [answer:%o]",w),await this._pc.setRemoteDescription(w),this._mapMidTransceiver.set(_,f),{localId:_,rtpParameters:a,rtpSender:f.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;g.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();g.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),g.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();g.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),g.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();g.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?g.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):g.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),g.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();g.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),g.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const i=r.sender.getParameters();i.encodings.forEach(((e,r)=>{i.encodings[r]={...e,...t}})),await r.sender.setParameters(i),this._remoteSdp.muxMediaSectionSimulcast(e,i.encodings);const n=await this._pc.createOffer();g.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",n),await this._pc.setLocalDescription(n);const a={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",a),await this._pc.setRemoteDescription(a)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:i,protocol:n}){this.assertNotClosed(),this.assertSendDirection();const a={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:n};g.debug("sendDataChannel() [options:%o]",a);const o=this._pc.createDataChannel(i,a);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%v.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=s.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),g.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const i={type:"answer",sdp:this._remoteSdp.getSdp()};g.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",i),await this._pc.setRemoteDescription(i),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:a.id,ordered:a.ordered,maxPacketLifeTime:a.maxPacketLifeTime,maxRetransmits:a.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:i,rtpParameters:n,streamId:a}=t;g.debug("receive() [trackId:%s, kind:%s]",e,i);const s=n.mid||String(this._mapMidTransceiver.size);r.set(e,s),this._remoteSdp.receive({mid:s,kind:i,offerRtpParameters:n,streamId:a||n.rtcp.cname,trackId:e})}const i={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",i),await this._pc.setRemoteDescription(i);for(const t of e){const{trackId:e,onRtpReceiver:i}=t;if(i){const t=r.get(e),n=this._pc.getTransceivers().find((e=>e.mid===t));if(!n)throw new Error("transceiver not found");i(n.receiver)}}let n=await this._pc.createAnswer();const a=s.parse(n.sdp);for(const t of e){const{trackId:e,rtpParameters:i}=t,n=r.get(e),s=a.media.find((e=>String(e.mid)===n));u.applyCodecParameters({offerRtpParameters:i,answerMediaObject:s})}n={type:"answer",sdp:s.write(a)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a}),g.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const i of e){const{trackId:e}=i,n=r.get(e),a=this._pc.getTransceivers().find((e=>e.mid===n));if(!a)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(n,a),t.push({localId:n,track:a.receiver.track,rtpReceiver:a.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){g.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){g.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){g.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();g.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o}=e,c={negotiated:!0,id:i,ordered:n,maxPacketLifeTime:a,maxRetransmits:o,protocol:r};g.debug("receiveDataChannel() [options:%o]",c);const d=this._pc.createDataChannel(t,c);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};g.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=s.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}g.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:d}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=s.parse(this._pc.localDescription.sdp));const r=u.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new f.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}r.Safari12=y},{"../Logger":206,"../errors":211,"../ortc":233,"../scalabilityModes":234,"../utils":236,"./HandlerInterface":220,"./ortc/utils":226,"./sdp/RemoteSdp":228,"./sdp/commonUtils":229,"./sdp/unifiedPlanUtils":231,"sdp-transform":286}],225:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.getCapabilities=function(){const e=RTCRtpReceiver.getCapabilities(),t=s.clone(e);for(const e of t.codecs??[]){if(e.channels=e.numChannels,delete e.numChannels,e.mimeType=e.mimeType||`${e.kind}/${e.name}`,e.parameters){const t=e.parameters;t.apt&&(t.apt=Number(t.apt)),t["packetization-mode"]&&(t["packetization-mode"]=Number(t["packetization-mode"]))}for(const t of e.rtcpFeedback||[])t.parameter||(t.parameter="")}return t},r.mangleRtpParameters=function(e){const t=s.clone(e);t.mid&&(t.muxId=t.mid,delete t.mid);for(const e of t.codecs)e.channels&&(e.numChannels=e.channels,delete e.channels),e.mimeType&&!e.name&&(e.name=e.mimeType.split("/")[1]),delete e.mimeType;return t};const s=a(e("../../utils"))},{"../../utils":236}],226:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.addNackSuppportForOpus=function(e){for(const t of e.codecs||[])"audio/opus"!==t.mimeType.toLowerCase()&&"audio/multiopus"!==t.mimeType.toLowerCase()||t.rtcpFeedback?.some((e=>"nack"===e.type&&!e.parameter))||(t.rtcpFeedback||(t.rtcpFeedback=[]),t.rtcpFeedback.push({type:"nack"}))}},{}],227:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.OfferMediaSection=r.AnswerMediaSection=r.MediaSection=void 0;const s=a(e("sdp-transform")),o=a(e("../../utils"));class c{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:i=!1}){if(this._mediaObject={},this._planB=i,e&&this.setIceParameters(e),t){this._mediaObject.candidates=[];for(const e of t){const t={component:1};t.foundation=e.foundation,t.ip=e.address??e.ip,t.port=e.port,t.priority=e.priority,t.transport=e.protocol,t.type=e.type,e.tcpType&&(t.tcptype=e.tcpType),this._mediaObject.candidates.push(t)}this._mediaObject.endOfCandidates="end-of-candidates",this._mediaObject.iceOptions="renomination"}r&&this.setDtlsRole(r.role)}get mid(){return String(this._mediaObject.mid)}get closed(){return 0===this._mediaObject.port}getObject(){return this._mediaObject}setIceParameters(e){this._mediaObject.iceUfrag=e.usernameFragment,this._mediaObject.icePwd=e.password}pause(){this._mediaObject.direction="inactive"}disable(){this.pause(),delete this._mediaObject.ext,delete this._mediaObject.ssrcs,delete this._mediaObject.ssrcGroups,delete this._mediaObject.simulcast,delete this._mediaObject.simulcast_03,delete this._mediaObject.rids,delete this._mediaObject.extmapAllowMixed}close(){this.disable(),this._mediaObject.port=0}}r.MediaSection=c;r.AnswerMediaSection=class extends c{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:i,plainRtpParameters:n,planB:a=!1,offerMediaObject:s,offerRtpParameters:c,answerRtpParameters:u,codecOptions:l,extmapAllowMixed:h=!1}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:a}),this._mediaObject.mid=String(s.mid),this._mediaObject.type=s.type,this._mediaObject.protocol=s.protocol,n?(this._mediaObject.connection={ip:n.ip,version:n.ipVersion},this._mediaObject.port=n.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.port=7),s.type){case"audio":case"video":this._mediaObject.direction="recvonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[];for(const e of u.codecs){const t={payload:e.payloadType,codec:d(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r=o.clone(e.parameters)??{};let i=o.clone(e.rtcpFeedback)??[];if(l){const{opusStereo:t,opusFec:n,opusDtx:a,opusMaxPlaybackRate:s,opusMaxAverageBitrate:o,opusPtime:d,opusNack:u,videoGoogleStartBitrate:h,videoGoogleMaxBitrate:f,videoGoogleMinBitrate:p}=l,m=c.codecs.find((t=>t.payloadType===e.payloadType));switch(e.mimeType.toLowerCase()){case"audio/opus":case"audio/multiopus":void 0!==t&&(m.parameters["sprop-stereo"]=t?1:0,r.stereo=t?1:0),void 0!==n&&(m.parameters.useinbandfec=n?1:0,r.useinbandfec=n?1:0),void 0!==a&&(m.parameters.usedtx=a?1:0,r.usedtx=a?1:0),void 0!==s&&(r.maxplaybackrate=s),void 0!==o&&(r.maxaveragebitrate=o),void 0!==d&&(m.parameters.ptime=d,r.ptime=d),u||(m.rtcpFeedback=m.rtcpFeedback.filter((e=>"nack"!==e.type||e.parameter)),i=i.filter((e=>"nack"!==e.type||e.parameter)));break;case"video/vp8":case"video/vp9":case"video/h264":case"video/h265":void 0!==h&&(r["x-google-start-bitrate"]=h),void 0!==f&&(r["x-google-max-bitrate"]=f),void 0!==p&&(r["x-google-min-bitrate"]=p)}}const n={payload:e.payloadType,config:""};for(const e of Object.keys(r))n.config&&(n.config+=";"),n.config+=`${e}=${r[e]}`;n.config&&this._mediaObject.fmtp.push(n);for(const t of i)this._mediaObject.rtcpFb.push({payload:e.payloadType,type:t.type,subtype:t.parameter})}this._mediaObject.payloads=u.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of u.headerExtensions){(s.ext||[]).some((t=>t.uri===e.uri))&&this._mediaObject.ext.push({uri:e.uri,value:e.id})}if(h&&"extmap-allow-mixed"===s.extmapAllowMixed&&(this._mediaObject.extmapAllowMixed="extmap-allow-mixed"),s.simulcast){this._mediaObject.simulcast={dir1:"recv",list1:s.simulcast.list1},this._mediaObject.rids=[];for(const e of s.rids||[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}else if(s.simulcast_03){this._mediaObject.simulcast_03={value:s.simulcast_03.value.replace(/send/g,"recv")},this._mediaObject.rids=[];for(const e of s.rids||[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize",this._planB&&"video"===this._mediaObject.type&&(this._mediaObject.xGoogleFlag="conference");break;case"application":"number"==typeof s.sctpPort?(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=i.port,this._mediaObject.maxMessageSize=i.maxMessageSize):s.sctpmap&&(this._mediaObject.payloads=i.port,this._mediaObject.sctpmap={app:"webrtc-datachannel",sctpmapNumber:i.port,maxMessageSize:i.maxMessageSize})}}setDtlsRole(e){switch(e){case"client":this._mediaObject.setup="active";break;case"server":this._mediaObject.setup="passive";break;case"auto":this._mediaObject.setup="actpass"}}resume(){this._mediaObject.direction="recvonly"}muxSimulcastStreams(e){if(!this._mediaObject.simulcast||!this._mediaObject.simulcast.list1)return;const t={};for(const r of e)r.rid&&(t[r.rid]=r);const r=this._mediaObject.simulcast.list1,i=s.parseSimulcastStreamList(r);for(const e of i)for(const r of e)r.paused=!t[r.scid]?.active;this._mediaObject.simulcast.list1=i.map((e=>e.map((e=>`${e.paused?"~":""}${e.scid}`)).join(","))).join(";")}};function d(e){const t=new RegExp("^(audio|video)/(.+)","i").exec(e.mimeType);if(!t)throw new TypeError("invalid codec.mimeType");return t[2]}r.OfferMediaSection=class extends c{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:i,plainRtpParameters:n,planB:a=!1,mid:s,kind:o,offerRtpParameters:c,streamId:u,trackId:l,oldDataChannelSpec:h=!1}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:a}),this._mediaObject.mid=String(s),this._mediaObject.type=o,n?(this._mediaObject.connection={ip:n.ip,version:n.ipVersion},this._mediaObject.protocol="RTP/AVP",this._mediaObject.port=n.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.protocol=i?"UDP/DTLS/SCTP":"UDP/TLS/RTP/SAVPF",this._mediaObject.port=7),o){case"audio":case"video":{this._mediaObject.direction="sendonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[],this._planB||(this._mediaObject.msid=`${u||"-"} ${l}`);for(const e of c.codecs){const t={payload:e.payloadType,codec:d(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r={payload:e.payloadType,config:""};for(const t of Object.keys(e.parameters))r.config&&(r.config+=";"),r.config+=`${t}=${e.parameters[t]}`;r.config&&this._mediaObject.fmtp.push(r);for(const t of e.rtcpFeedback)this._mediaObject.rtcpFb.push({payload:e.payloadType,type:t.type,subtype:t.parameter})}this._mediaObject.payloads=c.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of c.headerExtensions)this._mediaObject.ext.push({uri:e.uri,value:e.id});this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize";const e=c.encodings[0],t=e.ssrc,r=e.rtx&&e.rtx.ssrc?e.rtx.ssrc:void 0;this._mediaObject.ssrcs=[],this._mediaObject.ssrcGroups=[],c.rtcp.cname&&this._mediaObject.ssrcs.push({id:t,attribute:"cname",value:c.rtcp.cname}),this._planB&&this._mediaObject.ssrcs.push({id:t,attribute:"msid",value:`${u||"-"} ${l}`}),r&&(c.rtcp.cname&&this._mediaObject.ssrcs.push({id:r,attribute:"cname",value:c.rtcp.cname}),this._planB&&this._mediaObject.ssrcs.push({id:r,attribute:"msid",value:`${u||"-"} ${l}`}),this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}));break}case"application":h?(this._mediaObject.payloads=i.port,this._mediaObject.sctpmap={app:"webrtc-datachannel",sctpmapNumber:i.port,maxMessageSize:i.maxMessageSize}):(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=i.port,this._mediaObject.maxMessageSize=i.maxMessageSize)}}setDtlsRole(e){this._mediaObject.setup="actpass"}resume(){this._mediaObject.direction="sendonly"}planBReceive({offerRtpParameters:e,streamId:t,trackId:r}){const i=e.encodings[0],n=i.ssrc,a=i.rtx&&i.rtx.ssrc?i.rtx.ssrc:void 0,s=this._mediaObject.payloads.split(" ");for(const t of e.codecs){if(s.includes(String(t.payloadType)))continue;const e={payload:t.payloadType,codec:d(t),rate:t.clockRate};t.channels>1&&(e.encoding=t.channels),this._mediaObject.rtp.push(e);const r={payload:t.payloadType,config:""};for(const e of Object.keys(t.parameters))r.config&&(r.config+=";"),r.config+=`${e}=${t.parameters[e]}`;r.config&&this._mediaObject.fmtp.push(r);for(const e of t.rtcpFeedback)this._mediaObject.rtcpFb.push({payload:t.payloadType,type:e.type,subtype:e.parameter})}this._mediaObject.payloads+=` ${e.codecs.filter((e=>!this._mediaObject.payloads.includes(e.payloadType))).map((e=>e.payloadType)).join(" ")}`,this._mediaObject.payloads=this._mediaObject.payloads.trim(),e.rtcp.cname&&this._mediaObject.ssrcs.push({id:n,attribute:"cname",value:e.rtcp.cname}),this._mediaObject.ssrcs.push({id:n,attribute:"msid",value:`${t||"-"} ${r}`}),a&&(e.rtcp.cname&&this._mediaObject.ssrcs.push({id:a,attribute:"cname",value:e.rtcp.cname}),this._mediaObject.ssrcs.push({id:a,attribute:"msid",value:`${t||"-"} ${r}`}),this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${n} ${a}`}))}planBStopReceiving({offerRtpParameters:e}){const t=e.encodings[0],r=t.ssrc,i=t.rtx&&t.rtx.ssrc?t.rtx.ssrc:void 0;this._mediaObject.ssrcs=this._mediaObject.ssrcs.filter((e=>e.id!==r&&e.id!==i)),i&&(this._mediaObject.ssrcGroups=this._mediaObject.ssrcGroups.filter((e=>e.ssrcs!==`${r} ${i}`)))}}},{"../../utils":236,"sdp-transform":286}],228:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.RemoteSdp=void 0;const s=a(e("sdp-transform")),o=e("../../Logger"),c=e("./MediaSection"),d=new o.Logger("RemoteSdp");r.RemoteSdp=class{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:i,plainRtpParameters:n,planB:a=!1}){if(this._mediaSections=[],this._midToIndex=new Map,this._iceParameters=e,this._iceCandidates=t,this._dtlsParameters=r,this._sctpParameters=i,this._plainRtpParameters=n,this._planB=a,this._sdpObject={version:0,origin:{address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:1e4,sessionVersion:0,username:"mediasoup-client"},name:"-",timing:{start:0,stop:0},media:[]},e&&e.iceLite&&(this._sdpObject.icelite="ice-lite"),r){this._sdpObject.msidSemantic={semantic:"WMS",token:"*"};const e=this._dtlsParameters.fingerprints.length;this._sdpObject.fingerprint={type:r.fingerprints[e-1].algorithm,hash:r.fingerprints[e-1].value},this._sdpObject.groups=[{type:"BUNDLE",mids:""}]}n&&(this._sdpObject.origin.address=n.ip,this._sdpObject.origin.ipVer=n.ipVersion)}updateIceParameters(e){d.debug("updateIceParameters() [iceParameters:%o]",e),this._iceParameters=e,this._sdpObject.icelite=e.iceLite?"ice-lite":void 0;for(const t of this._mediaSections)t.setIceParameters(e)}updateDtlsRole(e){d.debug("updateDtlsRole() [role:%s]",e),this._dtlsParameters.role=e;for(const t of this._mediaSections)t.setDtlsRole(e)}getNextMediaSectionIdx(){for(let e=0;e<this._mediaSections.length;++e){const t=this._mediaSections[e];if(t.closed)return{idx:e,reuseMid:t.mid}}return{idx:this._mediaSections.length}}send({offerMediaObject:e,reuseMid:t,offerRtpParameters:r,answerRtpParameters:i,codecOptions:n,extmapAllowMixed:a=!1}){const s=new c.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,planB:this._planB,offerMediaObject:e,offerRtpParameters:r,answerRtpParameters:i,codecOptions:n,extmapAllowMixed:a});t?this._replaceMediaSection(s,t):this._midToIndex.has(s.mid)?this._replaceMediaSection(s):this._addMediaSection(s)}receive({mid:e,kind:t,offerRtpParameters:r,streamId:i,trackId:n}){const a=this._midToIndex.get(e);let s;if(void 0!==a&&(s=this._mediaSections[a]),s)s.planBReceive({offerRtpParameters:r,streamId:i,trackId:n}),this._replaceMediaSection(s);else{s=new c.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,planB:this._planB,mid:e,kind:t,offerRtpParameters:r,streamId:i,trackId:n});const a=this._mediaSections.find((e=>e.closed));a?this._replaceMediaSection(s,a.mid):this._addMediaSection(s)}}pauseMediaSection(e){this._findMediaSection(e).pause()}resumeSendingMediaSection(e){this._findMediaSection(e).resume()}resumeReceivingMediaSection(e){this._findMediaSection(e).resume()}disableMediaSection(e){this._findMediaSection(e).disable()}closeMediaSection(e){const t=this._findMediaSection(e);return e===this._firstMid?(d.debug("closeMediaSection() | cannot close first media section, disabling it instead [mid:%s]",e),this.disableMediaSection(e),!1):(t.close(),this._regenerateBundleMids(),!0)}muxMediaSectionSimulcast(e,t){const r=this._findMediaSection(e);r.muxSimulcastStreams(t),this._replaceMediaSection(r)}planBStopReceiving({mid:e,offerRtpParameters:t}){const r=this._findMediaSection(e);r.planBStopReceiving({offerRtpParameters:t}),this._replaceMediaSection(r)}sendSctpAssociation({offerMediaObject:e}){const t=new c.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,offerMediaObject:e});this._addMediaSection(t)}receiveSctpAssociation({oldDataChannelSpec:e=!1}={}){const t=new c.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,mid:"datachannel",kind:"application",oldDataChannelSpec:e});this._addMediaSection(t)}getSdp(){return this._sdpObject.origin.sessionVersion++,s.write(this._sdpObject)}_addMediaSection(e){this._firstMid||(this._firstMid=e.mid),this._mediaSections.push(e),this._midToIndex.set(e.mid,this._mediaSections.length-1),this._sdpObject.media.push(e.getObject()),this._regenerateBundleMids()}_replaceMediaSection(e,t){if("string"==typeof t){const r=this._midToIndex.get(t);if(void 0===r)throw new Error(`no media section found for reuseMid '${t}'`);const i=this._mediaSections[r];this._mediaSections[r]=e,this._midToIndex.delete(i.mid),this._midToIndex.set(e.mid,r),this._sdpObject.media[r]=e.getObject(),this._regenerateBundleMids()}else{const t=this._midToIndex.get(e.mid);if(void 0===t)throw new Error(`no media section found with mid '${e.mid}'`);this._mediaSections[t]=e,this._sdpObject.media[t]=e.getObject()}}_findMediaSection(e){const t=this._midToIndex.get(e);if(void 0===t)throw new Error(`no media section found with mid '${e}'`);return this._mediaSections[t]}_regenerateBundleMids(){this._dtlsParameters&&(this._sdpObject.groups[0].mids=this._mediaSections.filter((e=>!e.closed)).map((e=>e.mid)).join(" "))}}},{"../../Logger":206,"./MediaSection":227,"sdp-transform":286}],229:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.extractRtpCapabilities=function({sdpObject:e}){const t=new Map,r=[];let i=!1,n=!1;for(const a of e.media){const e=a.type;switch(e){case"audio":if(i)continue;i=!0;break;case"video":if(n)continue;n=!0;break;default:continue}for(const r of a.rtp){const i={kind:e,mimeType:`${e}/${r.codec}`,preferredPayloadType:r.payload,clockRate:r.rate,channels:r.encoding,parameters:{},rtcpFeedback:[]};t.set(i.preferredPayloadType,i)}for(const e of a.fmtp||[]){const r=s.parseParams(e.config),i=t.get(e.payload);i&&(r&&r.hasOwnProperty("profile-level-id")&&(r["profile-level-id"]=String(r["profile-level-id"])),i.parameters=r)}for(const r of a.rtcpFb||[]){const i={type:r.type,parameter:r.subtype};if(i.parameter||delete i.parameter,"*"!==r.payload){const e=t.get(r.payload);if(!e)continue;e.rtcpFeedback.push(i)}else for(const r of t.values())r.kind!==e||/.+\/rtx$/i.test(r.mimeType)||r.rtcpFeedback.push(i)}for(const t of a.ext||[]){if(t["encrypt-uri"])continue;const i={kind:e,uri:t.uri,preferredId:t.value};r.push(i)}}return{codecs:Array.from(t.values()),headerExtensions:r}},r.extractDtlsParameters=function({sdpObject:e}){let t,r=e.setup,i=e.fingerprint;if(!r||!i){const t=(e.media||[]).find((e=>0!==e.port));t&&(r??(r=t.setup),i??(i=t.fingerprint))}if(!r)throw new Error("no a=setup found at SDP session or media level");if(!i)throw new Error("no a=fingerprint found at SDP session or media level");switch(r){case"active":t="client";break;case"passive":t="server";break;case"actpass":t="auto"}return{role:t,fingerprints:[{algorithm:i.type,value:i.hash}]}},r.getCname=function({offerMediaObject:e}){const t=(e.ssrcs||[]).find((e=>"cname"===e.attribute));if(!t)return"";return t.value},r.applyCodecParameters=function({offerRtpParameters:e,answerMediaObject:t}){for(const r of e.codecs){const e=r.mimeType.toLowerCase();if("audio/opus"!==e)continue;if(!(t.rtp||[]).find((e=>e.payload===r.payloadType)))continue;t.fmtp=t.fmtp||[];let i=t.fmtp.find((e=>e.payload===r.payloadType));i||(i={payload:r.payloadType,config:""},t.fmtp.push(i));const n=s.parseParams(i.config);switch(e){case"audio/opus":{const e=r.parameters["sprop-stereo"];void 0!==e&&(n.stereo=e?1:0);break}}i.config="";for(const e of Object.keys(n))i.config&&(i.config+=";"),i.config+=`${e}=${n[e]}`}};const s=a(e("sdp-transform"))},{"sdp-transform":286}],230:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getRtpEncodings=function({offerMediaObject:e,track:t}){let r;const i=new Set;for(const n of e.ssrcs||[]){if("msid"!==n.attribute)continue;if(n.value.split(" ")[1]===t.id){const e=n.id;i.add(e),r||(r=e)}}if(0===i.size)throw new Error(`a=ssrc line with msid information not found [track.id:${t.id}]`);const n=new Map;for(const t of e.ssrcGroups||[]){if("FID"!==t.semantics)continue;let[e,r]=t.ssrcs.split(/\s+/);e=Number(e),r=Number(r),i.has(e)&&(i.delete(e),i.delete(r),n.set(e,r))}for(const e of i)n.set(e,null);const a=[];for(const[e,t]of n){const r={ssrc:e};t&&(r.rtx={ssrc:t}),a.push(r)}return a},r.addLegacySimulcast=function({offerMediaObject:e,track:t,numStreams:r}){if(r<=1)throw new TypeError("numStreams must be greater than 1");let i,n,a;if(!(e.ssrcs||[]).find((e=>{if("msid"!==e.attribute)return!1;return e.value.split(" ")[1]===t.id&&(i=e.id,a=e.value.split(" ")[0],!0)})))throw new Error(`a=ssrc line with msid information not found [track.id:${t.id}]`);(e.ssrcGroups||[]).some((e=>{if("FID"!==e.semantics)return!1;const t=e.ssrcs.split(/\s+/);return Number(t[0])===i&&(n=Number(t[1]),!0)}));const s=e.ssrcs.find((e=>"cname"===e.attribute&&e.id===i));if(!s)throw new Error(`a=ssrc line with cname information not found [track.id:${t.id}]`);const o=s.value,c=[],d=[];for(let e=0;e<r;++e)c.push(i+e),n&&d.push(n+e);e.ssrcGroups=e.ssrcGroups||[],e.ssrcs=e.ssrcs||[],e.ssrcGroups.push({semantics:"SIM",ssrcs:c.join(" ")});for(let r=0;r<c.length;++r){const i=c[r];e.ssrcs.push({id:i,attribute:"cname",value:o}),e.ssrcs.push({id:i,attribute:"msid",value:`${a} ${t.id}`})}for(let r=0;r<d.length;++r){const i=c[r],n=d[r];e.ssrcs.push({id:n,attribute:"cname",value:o}),e.ssrcs.push({id:n,attribute:"msid",value:`${a} ${t.id}`}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${i} ${n}`})}}},{}],231:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getRtpEncodings=function({offerMediaObject:e}){const t=new Set;for(const r of e.ssrcs||[]){const e=r.id;t.add(e)}if(0===t.size)throw new Error("no a=ssrc lines found");const r=new Map;for(const i of e.ssrcGroups||[]){if("FID"!==i.semantics)continue;let[e,n]=i.ssrcs.split(/\s+/);e=Number(e),n=Number(n),t.has(e)&&(t.delete(e),t.delete(n),r.set(e,n))}for(const e of t)r.set(e,null);const i=[];for(const[e,t]of r){const r={ssrc:e};t&&(r.rtx={ssrc:t}),i.push(r)}return i},r.addLegacySimulcast=function({offerMediaObject:e,numStreams:t}){if(t<=1)throw new TypeError("numStreams must be greater than 1");const r=(e.ssrcs||[]).find((e=>"msid"===e.attribute));if(!r)throw new Error("a=ssrc line with msid information not found");const[i,n]=r.value.split(" "),a=r.id;let s;(e.ssrcGroups||[]).some((e=>{if("FID"!==e.semantics)return!1;const t=e.ssrcs.split(/\s+/);return Number(t[0])===a&&(s=Number(t[1]),!0)}));const o=e.ssrcs.find((e=>"cname"===e.attribute));if(!o)throw new Error("a=ssrc line with cname information not found");const c=o.value,d=[],u=[];for(let e=0;e<t;++e)d.push(a+e),s&&u.push(s+e);e.ssrcGroups=[],e.ssrcs=[],e.ssrcGroups.push({semantics:"SIM",ssrcs:d.join(" ")});for(let t=0;t<d.length;++t){const r=d[t];e.ssrcs.push({id:r,attribute:"cname",value:c}),e.ssrcs.push({id:r,attribute:"msid",value:`${i} ${n}`})}for(let t=0;t<u.length;++t){const r=d[t],a=u[t];e.ssrcs.push({id:a,attribute:"cname",value:c}),e.ssrcs.push({id:a,attribute:"msid",value:`${i} ${n}`}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${r} ${a}`})}}},{}],232:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.debug=r.parseScalabilityMode=r.detectDevice=r.Device=r.version=r.types=void 0;const o=s(e("debug"));r.debug=o.default;const c=e("./Device");Object.defineProperty(r,"Device",{enumerable:!0,get:function(){return c.Device}}),Object.defineProperty(r,"detectDevice",{enumerable:!0,get:function(){return c.detectDevice}});const d=a(e("./types"));r.types=d,r.version="3.7.12";var u=e("./scalabilityModes");Object.defineProperty(r,"parseScalabilityMode",{enumerable:!0,get:function(){return u.parse}})},{"./Device":204,"./scalabilityModes":234,"./types":235,debug:104}],233:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.validateRtpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(e.codecs&&!Array.isArray(e.codecs))throw new TypeError("caps.codecs is not an array");e.codecs||(e.codecs=[]);for(const t of e.codecs)h(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("caps.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)p(t)},r.validateRtpParameters=l,r.validateSctpStreamParameters=function(e){if("object"!=typeof e)throw new TypeError("params is not an object");if("number"!=typeof e.streamId)throw new TypeError("missing params.streamId");let t=!1;"boolean"==typeof e.ordered?t=!0:e.ordered=!0;if(e.maxPacketLifeTime&&"number"!=typeof e.maxPacketLifeTime)throw new TypeError("invalid params.maxPacketLifeTime");if(e.maxRetransmits&&"number"!=typeof e.maxRetransmits)throw new TypeError("invalid params.maxRetransmits");if(e.maxPacketLifeTime&&e.maxRetransmits)throw new TypeError("cannot provide both maxPacketLifeTime and maxRetransmits");if(t&&e.ordered&&(e.maxPacketLifeTime||e.maxRetransmits))throw new TypeError("cannot be ordered with maxPacketLifeTime or maxRetransmits");t||!e.maxPacketLifeTime&&!e.maxRetransmits||(e.ordered=!1);if(e.label&&"string"!=typeof e.label)throw new TypeError("invalid params.label");if(e.protocol&&"string"!=typeof e.protocol)throw new TypeError("invalid params.protocol")},r.validateSctpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(!e.numStreams||"object"!=typeof e.numStreams)throw new TypeError("missing caps.numStreams");!function(e){if("object"!=typeof e)throw new TypeError("numStreams is not an object");if("number"!=typeof e.OS)throw new TypeError("missing numStreams.OS");if("number"!=typeof e.MIS)throw new TypeError("missing numStreams.MIS")}(e.numStreams)},r.getExtendedRtpCapabilities=function(e,t){const r={codecs:[],headerExtensions:[]};for(const i of t.codecs||[]){if(v(i))continue;const t=(e.codecs||[]).find((e=>y(e,i,{strict:!0,modify:!0})));if(!t)continue;const n={mimeType:t.mimeType,kind:t.kind,clockRate:t.clockRate,channels:t.channels,localPayloadType:t.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:i.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:t.parameters,remoteParameters:i.parameters,rtcpFeedback:w(t,i)};r.codecs.push(n)}for(const i of r.codecs){const r=e.codecs.find((e=>v(e)&&e.parameters.apt===i.localPayloadType)),n=t.codecs.find((e=>v(e)&&e.parameters.apt===i.remotePayloadType));r&&n&&(i.localRtxPayloadType=r.preferredPayloadType,i.remoteRtxPayloadType=n.preferredPayloadType)}for(const i of t.headerExtensions){const t=e.headerExtensions.find((e=>_(e,i)));if(!t)continue;const n={kind:i.kind,uri:i.uri,sendId:t.preferredId,recvId:i.preferredId,encrypt:t.preferredEncrypt,direction:"sendrecv"};switch(i.direction){case"sendrecv":n.direction="sendrecv";break;case"recvonly":n.direction="sendonly";break;case"sendonly":n.direction="recvonly";break;case"inactive":n.direction="inactive"}r.headerExtensions.push(n)}return r},r.getRecvRtpCapabilities=function(e){const t={codecs:[],headerExtensions:[]};for(const r of e.codecs){const e={mimeType:r.mimeType,kind:r.kind,preferredPayloadType:r.remotePayloadType,clockRate:r.clockRate,channels:r.channels,parameters:r.localParameters,rtcpFeedback:r.rtcpFeedback};if(t.codecs.push(e),!r.remoteRtxPayloadType)continue;const i={mimeType:`${r.kind}/rtx`,kind:r.kind,preferredPayloadType:r.remoteRtxPayloadType,clockRate:r.clockRate,parameters:{apt:r.remotePayloadType},rtcpFeedback:[]};t.codecs.push(i)}for(const r of e.headerExtensions){if("sendrecv"!==r.direction&&"recvonly"!==r.direction)continue;const e={kind:r.kind,uri:r.uri,preferredId:r.recvId,preferredEncrypt:r.encrypt,direction:r.direction};t.headerExtensions.push(e)}return t},r.getSendingRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const i of t.codecs){if(i.kind!==e)continue;const t={mimeType:i.mimeType,payloadType:i.localPayloadType,clockRate:i.clockRate,channels:i.channels,parameters:i.localParameters,rtcpFeedback:i.rtcpFeedback};if(r.codecs.push(t),i.localRtxPayloadType){const e={mimeType:`${i.kind}/rtx`,payloadType:i.localRtxPayloadType,clockRate:i.clockRate,parameters:{apt:i.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const i of t.headerExtensions){if(i.kind&&i.kind!==e||"sendrecv"!==i.direction&&"sendonly"!==i.direction)continue;const t={uri:i.uri,id:i.sendId,encrypt:i.encrypt,parameters:{}};r.headerExtensions.push(t)}return r},r.getSendingRemoteRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const i of t.codecs){if(i.kind!==e)continue;const t={mimeType:i.mimeType,payloadType:i.localPayloadType,clockRate:i.clockRate,channels:i.channels,parameters:i.remoteParameters,rtcpFeedback:i.rtcpFeedback};if(r.codecs.push(t),i.localRtxPayloadType){const e={mimeType:`${i.kind}/rtx`,payloadType:i.localRtxPayloadType,clockRate:i.clockRate,parameters:{apt:i.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const i of t.headerExtensions){if(i.kind&&i.kind!==e||"sendrecv"!==i.direction&&"sendonly"!==i.direction)continue;const t={uri:i.uri,id:i.sendId,encrypt:i.encrypt,parameters:{}};r.headerExtensions.push(t)}if(r.headerExtensions.some((e=>"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"===e.uri)))for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback||[]).filter((e=>"goog-remb"!==e.type));else if(r.headerExtensions.some((e=>"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"===e.uri)))for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback||[]).filter((e=>"transport-cc"!==e.type));else for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback||[]).filter((e=>"transport-cc"!==e.type&&"goog-remb"!==e.type));return r},r.reduceCodecs=function(e,t){const r=[];if(t){for(let i=0;i<e.length;++i)if(y(e[i],t,{strict:!0})){r.push(e[i]),v(e[i+1])&&r.push(e[i+1]);break}if(0===r.length)throw new TypeError("no matching codec found")}else r.push(e[0]),v(e[1])&&r.push(e[1]);return r},r.generateProbatorRtpParameters=function(e){l(e=o.clone(e));const t={mid:c,codecs:[],headerExtensions:[],encodings:[{ssrc:d}],rtcp:{cname:"probator"}};return t.codecs.push(e.codecs[0]),t.codecs[0].payloadType=u,t.headerExtensions=e.headerExtensions,t},r.canSend=function(e,t){return t.codecs.some((t=>t.kind===e))},r.canReceive=function(e,t){if(l(e),0===e.codecs.length)return!1;const r=e.codecs[0];return t.codecs.some((e=>e.remotePayloadType===r.payloadType))};const s=a(e("h264-profile-level-id")),o=a(e("./utils")),c="probator",d=1234,u=127;function l(e){if("object"!=typeof e)throw new TypeError("params is not an object");if(e.mid&&"string"!=typeof e.mid)throw new TypeError("params.mid is not a string");if(!Array.isArray(e.codecs))throw new TypeError("missing params.codecs");for(const t of e.codecs)m(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("params.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)b(t);if(e.encodings&&!Array.isArray(e.encodings))throw new TypeError("params.encodings is not an array");e.encodings||(e.encodings=[]);for(const t of e.encodings)g(t);if(e.rtcp&&"object"!=typeof e.rtcp)throw new TypeError("params.rtcp is not an object");e.rtcp||(e.rtcp={}),function(e){if("object"!=typeof e)throw new TypeError("rtcp is not an object");if(e.cname&&"string"!=typeof e.cname)throw new TypeError("invalid rtcp.cname");e.reducedSize&&"boolean"==typeof e.reducedSize||(e.reducedSize=!0)}(e.rtcp)}function h(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if(e.kind=r[1].toLowerCase(),e.preferredPayloadType&&"number"!=typeof e.preferredPayloadType)throw new TypeError("invalid codec.preferredPayloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===e.kind?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError(`invalid codec parameter [key:${t}s, value:${r}]`);if("apt"===t&&"number"!=typeof r)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const t of e.rtcpFeedback)f(t)}function f(e){if("object"!=typeof e)throw new TypeError("fb is not an object");if(!e.type||"string"!=typeof e.type)throw new TypeError("missing fb.type");e.parameter&&"string"==typeof e.parameter||(e.parameter="")}function p(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if("audio"!==e.kind&&"video"!==e.kind)throw new TypeError("invalid ext.kind");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.preferredId)throw new TypeError("missing ext.preferredId");if(e.preferredEncrypt&&"boolean"!=typeof e.preferredEncrypt)throw new TypeError("invalid ext.preferredEncrypt");if(e.preferredEncrypt||(e.preferredEncrypt=!1),e.direction&&"string"!=typeof e.direction)throw new TypeError("invalid ext.direction");e.direction||(e.direction="sendrecv")}function m(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if("number"!=typeof e.payloadType)throw new TypeError("missing codec.payloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===r[1].toLowerCase()?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError(`invalid codec parameter [key:${t}s, value:${r}]`);if("apt"===t&&"number"!=typeof r)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const t of e.rtcpFeedback)f(t)}function b(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.id)throw new TypeError("missing ext.id");if(e.encrypt&&"boolean"!=typeof e.encrypt)throw new TypeError("invalid ext.encrypt");e.encrypt||(e.encrypt=!1),e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError("invalid header extension parameter")}}function g(e){if("object"!=typeof e)throw new TypeError("encoding is not an object");if(e.ssrc&&"number"!=typeof e.ssrc)throw new TypeError("invalid encoding.ssrc");if(e.rid&&"string"!=typeof e.rid)throw new TypeError("invalid encoding.rid");if(e.rtx&&"object"!=typeof e.rtx)throw new TypeError("invalid encoding.rtx");if(e.rtx&&"number"!=typeof e.rtx.ssrc)throw new TypeError("missing encoding.rtx.ssrc");if(e.dtx&&"boolean"==typeof e.dtx||(e.dtx=!1),e.scalabilityMode&&"string"!=typeof e.scalabilityMode)throw new TypeError("invalid encoding.scalabilityMode")}function v(e){return!!e&&/.+\/rtx$/i.test(e.mimeType)}function y(e,t,{strict:r=!1,modify:i=!1}={}){const n=e.mimeType.toLowerCase();if(n!==t.mimeType.toLowerCase())return!1;if(e.clockRate!==t.clockRate)return!1;if(e.channels!==t.channels)return!1;switch(n){case"video/h264":if(r){if((e.parameters["packetization-mode"]||0)!==(t.parameters["packetization-mode"]||0))return!1;if(!s.isSameProfile(e.parameters,t.parameters))return!1;let r;try{r=s.generateProfileLevelIdStringForAnswer(e.parameters,t.parameters)}catch(e){return!1}i&&(r?(e.parameters["profile-level-id"]=r,t.parameters["profile-level-id"]=r):(delete e.parameters["profile-level-id"],delete t.parameters["profile-level-id"]))}break;case"video/vp9":if(r){if((e.parameters["profile-id"]||0)!==(t.parameters["profile-id"]||0))return!1}}return!0}function _(e,t){return(!e.kind||!t.kind||e.kind===t.kind)&&e.uri===t.uri}function w(e,t){const r=[];for(const i of e.rtcpFeedback||[]){const e=(t.rtcpFeedback||[]).find((e=>e.type===i.type&&(e.parameter===i.parameter||!e.parameter&&!i.parameter)));e&&r.push(e)}return r}},{"./utils":236,"h264-profile-level-id":158}],234:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parse=function(e){const t=i.exec(e||"");return t?{spatialLayers:Number(t[1]),temporalLayers:Number(t[2])}:{spatialLayers:1,temporalLayers:1}};const i=new RegExp("^[LS]([1-9]\\d{0,1})T([1-9]\\d{0,1})")},{}],235:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),n(e("./Device"),r),n(e("./Transport"),r),n(e("./Producer"),r),n(e("./Consumer"),r),n(e("./DataProducer"),r),n(e("./DataConsumer"),r),n(e("./RtpParameters"),r),n(e("./SctpParameters"),r),n(e("./handlers/HandlerInterface"),r),n(e("./errors"),r)},{"./Consumer":201,"./DataConsumer":202,"./DataProducer":203,"./Device":204,"./Producer":207,"./RtpParameters":208,"./SctpParameters":209,"./Transport":210,"./errors":211,"./handlers/HandlerInterface":220}],236:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},r.generateRandomNumber=function(){return Math.round(1e7*Math.random())},r.deepFreeze=function e(t){const r=Reflect.ownKeys(t);for(const i of r){const r=t[i];(r&&"object"==typeof r||"function"==typeof r)&&e(r)}return Object.freeze(t)}},{}],237:[function(e,t,r){var i=e("bn.js"),n=e("brorand");function a(e){this.rand=e||new n.Rand}t.exports=a,a.create=function(e){return new a(e)},a.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var n=new i(this.rand.generate(r))}while(n.cmp(e)>=0);return n},a.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},a.prototype.test=function(e,t,r){var n=e.bitLength(),a=i.mont(e),s=new i(1).toRed(a);t||(t=Math.max(1,n/48|0));for(var o=e.subn(1),c=0;!o.testn(c);c++);for(var d=e.shrn(c),u=o.toRed(a);t>0;t--){var l=this._randrange(new i(2),o);r&&r(l);var h=l.toRed(a).redPow(d);if(0!==h.cmp(s)&&0!==h.cmp(u)){for(var f=1;f<c;f++){if(0===(h=h.redSqr()).cmp(s))return!1;if(0===h.cmp(u))break}if(f===c)return!1}}return!0},a.prototype.getDivisor=function(e,t){var r=e.bitLength(),n=i.mont(e),a=new i(1).toRed(n);t||(t=Math.max(1,r/48|0));for(var s=e.subn(1),o=0;!s.testn(o);o++);for(var c=e.shrn(o),d=s.toRed(n);t>0;t--){var u=this._randrange(new i(2),s),l=e.gcd(u);if(0!==l.cmpn(1))return l;var h=u.toRed(n).redPow(c);if(0!==h.cmp(a)&&0!==h.cmp(d)){for(var f=1;f<o;f++){if(0===(h=h.redSqr()).cmp(a))return h.fromRed().subn(1).gcd(e);if(0===h.cmp(d))break}if(f===o)return(h=h.redSqr()).fromRed().subn(1).gcd(e)}}return!1}},{"bn.js":238,brorand:62}],238:[function(e,t,r){arguments[4][55][0].apply(r,arguments)},{buffer:63,dup:55}],239:[function(e,t,r){function i(e,t){if(!e)throw new Error(t||"Assertion failed")}t.exports=i,i.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},{}],240:[function(e,t,r){"use strict";var i=r;function n(e){return 1===e.length?"0"+e:e}function a(e){for(var t="",r=0;r<e.length;r++)t+=n(e[r].toString(16));return t}i.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"!=typeof e){for(var i=0;i<e.length;i++)r[i]=0|e[i];return r}if("hex"===t){(e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e);for(i=0;i<e.length;i+=2)r.push(parseInt(e[i]+e[i+1],16))}else for(i=0;i<e.length;i++){var n=e.charCodeAt(i),a=n>>8,s=255&n;a?r.push(a,s):r.push(s)}return r},i.zero2=n,i.toHex=a,i.encode=function(e,t){return"hex"===t?a(e):e}},{}],241:[function(e,t,r){var i=1e3,n=60*i,a=60*n,s=24*a,o=7*s,c=365.25*s;function d(e,t,r,i){var n=t>=1.5*r;return Math.round(e/r)+" "+i+(n?"s":"")}t.exports=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*c;case"weeks":case"week":case"w":return r*o;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*a;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=s)return d(e,t,s,"day");if(t>=a)return d(e,t,a,"hour");if(t>=n)return d(e,t,n,"minute");if(t>=i)return d(e,t,i,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=s)return Math.round(e/s)+"d";if(t>=a)return Math.round(e/a)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=i)return Math.round(e/i)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],242:[function(e,t,r){"use strict";var i,n="object"==typeof Reflect?Reflect:null,a=n&&"function"==typeof n.apply?n.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};i=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(e,t){return new Promise((function(r,i){function n(r){e.removeListener(t,a),i(r)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}g(e,t,a,{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 c=10;function d(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function l(e,t,r,i){var n,a,s,o;if(d(r),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),s=a[t]),void 0===s)s=a[t]=r,++e._eventsCount;else if("function"==typeof s?s=a[t]=i?[r,s]:[s,r]:i?s.unshift(r):s.push(r),(n=u(e))>0&&s.length>n&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,o=c,console&&console.warn&&console.warn(o)}return e}function h(){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 f(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=h.bind(i);return n.listener=r,i.wrapFn=n,n}function p(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):b(n,n.length)}function m(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 b(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(a){i.once&&e.removeEventListener(t,n),r(a)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=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||s(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 u(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,n=this._events;if(void 0!==n)i=i&&void 0===n.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var c=n[e];if(void 0===c)return!1;if("function"==typeof c)a(c,this,t);else{var d=c.length,u=b(c,d);for(r=0;r<d;++r)a(u[r],this,t)}return!0},o.prototype.addListener=function(e,t){return l(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return l(this,e,t,!0)},o.prototype.once=function(e,t){return d(t),this.on(e,f(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return d(t),this.prependListener(e,f(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,i,n,a,s;if(d(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,a=r.length-1;a>=0;a--)if(r[a]===t||r[a].listener===t){s=r[a].listener,n=a;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,a=Object.keys(r);for(i=0;i<a.length;++i)"removeListener"!==(n=a[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 p(this,e,!0)},o.prototype.rawListeners=function(e){return p(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},o.prototype.listenerCount=m,o.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},{}],243:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],244:[function(e,t,r){"use strict";var i=e("asn1.js");r.certificate=e("./certificate");var n=i.define("RSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())}));r.RSAPrivateKey=n;var a=i.define("RSAPublicKey",(function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())}));r.RSAPublicKey=a;var s=i.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())})),o=i.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())}));r.PublicKey=o;var c=i.define("PrivateKeyInfo",(function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())}));r.PrivateKey=c;var d=i.define("EncryptedPrivateKeyInfo",(function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())}));r.EncryptedPrivateKey=d;var u=i.define("DSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())}));r.DSAPrivateKey=u,r.DSAparam=i.define("DSAparam",(function(){this.int()}));var l=i.define("ECParameters",(function(){this.choice({namedCurve:this.objid()})})),h=i.define("ECPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(l),this.key("publicKey").optional().explicit(1).bitstr())}));r.ECPrivateKey=h,r.signature=i.define("signature",(function(){this.seq().obj(this.key("r").int(),this.key("s").int())}))},{"./certificate":245,"asn1.js":41}],245:[function(e,t,r){"use strict";var i=e("asn1.js"),n=i.define("Time",(function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})})),a=i.define("AttributeTypeValue",(function(){this.seq().obj(this.key("type").objid(),this.key("value").any())})),s=i.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())})),o=i.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())})),c=i.define("RelativeDistinguishedName",(function(){this.setof(a)})),d=i.define("RDNSequence",(function(){this.seqof(c)})),u=i.define("Name",(function(){this.choice({rdnSequence:this.use(d)})})),l=i.define("Validity",(function(){this.seq().obj(this.key("notBefore").use(n),this.key("notAfter").use(n))})),h=i.define("Extension",(function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())})),f=i.define("TBSCertificate",(function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(s),this.key("issuer").use(u),this.key("validity").use(l),this.key("subject").use(u),this.key("subjectPublicKeyInfo").use(o),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(h).optional())})),p=i.define("X509Certificate",(function(){this.seq().obj(this.key("tbsCertificate").use(f),this.key("signatureAlgorithm").use(s),this.key("signatureValue").bitstr())}));t.exports=p},{"asn1.js":41}],246:[function(e,t,r){"use strict";var i=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,n=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,a=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,s=e("evp_bytestokey"),o=e("browserify-aes"),c=e("safe-buffer").Buffer;t.exports=function(e,t){var r,d=e.toString(),u=d.match(i);if(u){var l="aes"+u[1],h=c.from(u[2],"hex"),f=c.from(u[3].replace(/[\r\n]/g,""),"base64"),p=s(t,h.slice(0,8),parseInt(u[1],10)).key,m=[],b=o.createDecipheriv(l,p,h);m.push(b.update(f)),m.push(b.final()),r=c.concat(m)}else{var g=d.match(a);r=c.from(g[2].replace(/[\r\n]/g,""),"base64")}return{tag:d.match(n)[1],data:r}}},{"browserify-aes":66,evp_bytestokey:156,"safe-buffer":284}],247:[function(e,t,r){"use strict";var i=e("./asn1"),n=e("./aesid.json"),a=e("./fixProc"),s=e("browserify-aes"),o=e("pbkdf2"),c=e("safe-buffer").Buffer;function d(e){var t;"object"!=typeof e||c.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=c.from(e));var r,d,u=a(e,t),l=u.tag,h=u.data;switch(l){case"CERTIFICATE":d=i.certificate.decode(h,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(d||(d=i.PublicKey.decode(h,"der")),r=d.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return i.RSAPublicKey.decode(d.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return d.subjectPrivateKey=d.subjectPublicKey,{type:"ec",data:d};case"1.2.840.10040.4.1":return d.algorithm.params.pub_key=i.DSAparam.decode(d.subjectPublicKey.data,"der"),{type:"dsa",data:d.algorithm.params};default:throw new Error("unknown key id "+r)}case"ENCRYPTED PRIVATE KEY":h=function(e,t){var r=e.algorithm.decrypt.kde.kdeparams.salt,i=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),a=n[e.algorithm.decrypt.cipher.algo.join(".")],d=e.algorithm.decrypt.cipher.iv,u=e.subjectPrivateKey,l=parseInt(a.split("-")[1],10)/8,h=o.pbkdf2Sync(t,r,i,l,"sha1"),f=s.createDecipheriv(a,h,d),p=[];return p.push(f.update(u)),p.push(f.final()),c.concat(p)}(h=i.EncryptedPrivateKey.decode(h,"der"),t);case"PRIVATE KEY":switch(r=(d=i.PrivateKey.decode(h,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return i.RSAPrivateKey.decode(d.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:d.algorithm.curve,privateKey:i.ECPrivateKey.decode(d.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return d.algorithm.params.priv_key=i.DSAparam.decode(d.subjectPrivateKey,"der"),{type:"dsa",params:d.algorithm.params};default:throw new Error("unknown key id "+r)}case"RSA PUBLIC KEY":return i.RSAPublicKey.decode(h,"der");case"RSA PRIVATE KEY":return i.RSAPrivateKey.decode(h,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:i.DSAPrivateKey.decode(h,"der")};case"EC PRIVATE KEY":return{curve:(h=i.ECPrivateKey.decode(h,"der")).parameters.value,privateKey:h.privateKey};default:throw new Error("unknown key type "+l)}}d.signature=i.signature,t.exports=d},{"./aesid.json":243,"./asn1":244,"./fixProc":246,"browserify-aes":66,pbkdf2:248,"safe-buffer":284}],248:[function(e,t,r){r.pbkdf2=e("./lib/async"),r.pbkdf2Sync=e("./lib/sync")},{"./lib/async":249,"./lib/sync":252}],249:[function(e,t,r){(function(r){(function(){var i,n,a=e("safe-buffer").Buffer,s=e("./precondition"),o=e("./default-encoding"),c=e("./sync"),d=e("./to-buffer"),u=r.crypto&&r.crypto.subtle,l={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},h=[];function f(){return n||(n=r.process&&r.process.nextTick?r.process.nextTick:r.queueMicrotask?r.queueMicrotask:r.setImmediate?r.setImmediate:r.setTimeout)}function p(e,t,r,i,n){return u.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then((function(e){return u.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:n}},e,i<<3)})).then((function(e){return a.from(e)}))}t.exports=function(e,t,n,m,b,g){"function"==typeof b&&(g=b,b=void 0);var v=l[(b=b||"sha1").toLowerCase()];if(v&&"function"==typeof r.Promise){if(s(n,m),e=d(e,o,"Password"),t=d(t,o,"Salt"),"function"!=typeof g)throw new Error("No callback provided to pbkdf2");!function(e,t){e.then((function(e){f()((function(){t(null,e)}))}),(function(e){f()((function(){t(e)}))}))}(function(e){if(r.process&&!r.process.browser)return Promise.resolve(!1);if(!u||!u.importKey||!u.deriveBits)return Promise.resolve(!1);if(void 0!==h[e])return h[e];var t=p(i=i||a.alloc(8),i,10,128,e).then((function(){return!0})).catch((function(){return!1}));return h[e]=t,t}(v).then((function(r){return r?p(e,t,n,m,v):c(e,t,n,m,b)})),g)}else f()((function(){var r;try{r=c(e,t,n,m,b)}catch(e){return g(e)}g(null,r)}))}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":250,"./precondition":251,"./sync":252,"./to-buffer":253,"safe-buffer":284}],250:[function(e,t,r){(function(e,r){(function(){var i;if(r.process&&r.process.browser)i="utf-8";else if(r.process&&r.process.version){i=parseInt(e.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary"}else i="utf-8";t.exports=i}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257}],251:[function(e,t,r){var i=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>i||t!=t)throw new TypeError("Bad key length")}},{}],252:[function(e,t,r){var i=e("create-hash/md5"),n=e("ripemd160"),a=e("sha.js"),s=e("safe-buffer").Buffer,o=e("./precondition"),c=e("./default-encoding"),d=e("./to-buffer"),u=s.alloc(128),l={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function h(e,t,r){var o=function(e){function t(t){return a(e).update(t).digest()}function r(e){return(new n).update(e).digest()}return"rmd160"===e||"ripemd160"===e?r:"md5"===e?i:t}(e),c="sha512"===e||"sha384"===e?128:64;t.length>c?t=o(t):t.length<c&&(t=s.concat([t,u],c));for(var d=s.allocUnsafe(c+l[e]),h=s.allocUnsafe(c+l[e]),f=0;f<c;f++)d[f]=54^t[f],h[f]=92^t[f];var p=s.allocUnsafe(c+r+4);d.copy(p,0,0,c),this.ipad1=p,this.ipad2=d,this.opad=h,this.alg=e,this.blocksize=c,this.hash=o,this.size=l[e]}h.prototype.run=function(e,t){return e.copy(t,this.blocksize),this.hash(t).copy(this.opad,this.blocksize),this.hash(this.opad)},t.exports=function(e,t,r,i,n){o(r,i);var a=new h(n=n||"sha1",e=d(e,c,"Password"),(t=d(t,c,"Salt")).length),u=s.allocUnsafe(i),f=s.allocUnsafe(t.length+4);t.copy(f,0,0,t.length);for(var p=0,m=l[n],b=Math.ceil(i/m),g=1;g<=b;g++){f.writeUInt32BE(g,t.length);for(var v=a.run(f,a.ipad1),y=v,_=1;_<r;_++){y=a.run(y,a.ipad2);for(var w=0;w<m;w++)v[w]^=y[w]}v.copy(u,p),p+=m}return u}},{"./default-encoding":250,"./precondition":251,"./to-buffer":253,"create-hash/md5":100,ripemd160:283,"safe-buffer":284,"sha.js":290}],253:[function(e,t,r){var i=e("safe-buffer").Buffer;t.exports=function(e,t,r){if(i.isBuffer(e))return e;if("string"==typeof e)return i.from(e,t);if(ArrayBuffer.isView(e))return i.from(e.buffer);throw new TypeError(r+" must be a string, a Buffer, a typed array or a DataView")}},{"safe-buffer":284}],254:[function(e,t,r){t.exports=["Bulbasaur","Ivysaur","Venusaur","Charmander","Charmeleon","Charizard","Squirtle","Wartortle","Blastoise","Caterpie","Metapod","Butterfree","Weedle","Kakuna","Beedrill","Pidgey","Pidgeotto","Pidgeot","Rattata","Raticate","Spearow","Fearow","Ekans","Arbok","Pikachu","Raichu","Sandshrew","Sandslash","Nidoran♀","Nidorina","Nidoqueen","Nidoran♂","Nidorino","Nidoking","Clefairy","Clefable","Vulpix","Ninetales","Jigglypuff","Wigglytuff","Zubat","Golbat","Oddish","Gloom","Vileplume","Paras","Parasect","Venonat","Venomoth","Diglett","Dugtrio","Meowth","Persian","Psyduck","Golduck","Mankey","Primeape","Growlithe","Arcanine","Poliwag","Poliwhirl","Poliwrath","Abra","Kadabra","Alakazam","Machop","Machoke","Machamp","Bellsprout","Weepinbell","Victreebel","Tentacool","Tentacruel","Geodude","Graveler","Golem","Ponyta","Rapidash","Slowpoke","Slowbro","Magnemite","Magneton","Farfetch'd","Doduo","Dodrio","Seel","Dewgong","Grimer","Muk","Shellder","Cloyster","Gastly","Haunter","Gengar","Onix","Drowzee","Hypno","Krabby","Kingler","Voltorb","Electrode","Exeggcute","Exeggutor","Cubone","Marowak","Hitmonlee","Hitmonchan","Lickitung","Koffing","Weezing","Rhyhorn","Rhydon","Chansey","Tangela","Kangaskhan","Horsea","Seadra","Goldeen","Seaking","Staryu","Starmie","Mr. Mime","Scyther","Jynx","Electabuzz","Magmar","Pinsir","Tauros","Magikarp","Gyarados","Lapras","Ditto","Eevee","Vaporeon","Jolteon","Flareon","Porygon","Omanyte","Omastar","Kabuto","Kabutops","Aerodactyl","Snorlax","Articuno","Zapdos","Moltres","Dratini","Dragonair","Dragonite","Mewtwo","Mew","Chikorita","Bayleef","Meganium","Cyndaquil","Quilava","Typhlosion","Totodile","Croconaw","Feraligatr","Sentret","Furret","Hoothoot","Noctowl","Ledyba","Ledian","Spinarak","Ariados","Crobat","Chinchou","Lanturn","Pichu","Cleffa","Igglybuff","Togepi","Togetic","Natu","Xatu","Mareep","Flaaffy","Ampharos","Bellossom","Marill","Azumarill","Sudowoodo","Politoed","Hoppip","Skiploom","Jumpluff","Aipom","Sunkern","Sunflora","Yanma","Wooper","Quagsire","Espeon","Umbreon","Murkrow","Slowking","Misdreavus","Unown","Wobbuffet","Girafarig","Pineco","Forretress","Dunsparce","Gligar","Steelix","Snubbull","Granbull","Qwilfish","Scizor","Shuckle","Heracross","Sneasel","Teddiursa","Ursaring","Slugma","Magcargo","Swinub","Piloswine","Corsola","Remoraid","Octillery","Delibird","Mantine","Skarmory","Houndour","Houndoom","Kingdra","Phanpy","Donphan","Porygon2","Stantler","Smeargle","Tyrogue","Hitmontop","Smoochum","Elekid","Magby","Miltank","Blissey","Raikou","Entei","Suicune","Larvitar","Pupitar","Tyranitar","Lugia","Ho-Oh","Celebi","Treecko","Grovyle","Sceptile","Torchic","Combusken","Blaziken","Mudkip","Marshtomp","Swampert","Poochyena","Mightyena","Zigzagoon","Linoone","Wurmple","Silcoon","Beautifly","Cascoon","Dustox","Lotad","Lombre","Ludicolo","Seedot","Nuzleaf","Shiftry","Taillow","Swellow","Wingull","Pelipper","Ralts","Kirlia","Gardevoir","Surskit","Masquerain","Shroomish","Breloom","Slakoth","Vigoroth","Slaking","Nincada","Ninjask","Shedinja","Whismur","Loudred","Exploud","Makuhita","Hariyama","Azurill","Nosepass","Skitty","Delcatty","Sableye","Mawile","Aron","Lairon","Aggron","Meditite","Medicham","Electrike","Manectric","Plusle","Minun","Volbeat","Illumise","Roselia","Gulpin","Swalot","Carvanha","Sharpedo","Wailmer","Wailord","Numel","Camerupt","Torkoal","Spoink","Grumpig","Spinda","Trapinch","Vibrava","Flygon","Cacnea","Cacturne","Swablu","Altaria","Zangoose","Seviper","Lunatone","Solrock","Barboach","Whiscash","Corphish","Crawdaunt","Baltoy","Claydol","Lileep","Cradily","Anorith","Armaldo","Feebas","Milotic","Castform","Kecleon","Shuppet","Banette","Duskull","Dusclops","Tropius","Chimecho","Absol","Wynaut","Snorunt","Glalie","Spheal","Sealeo","Walrein","Clamperl","Huntail","Gorebyss","Relicanth","Luvdisc","Bagon","Shelgon","Salamence","Beldum","Metang","Metagross","Regirock","Regice","Registeel","Latias","Latios","Kyogre","Groudon","Rayquaza","Jirachi","Deoxys","Turtwig","Grotle","Torterra","Chimchar","Monferno","Infernape","Piplup","Prinplup","Empoleon","Starly","Staravia","Staraptor","Bidoof","Bibarel","Kricketot","Kricketune","Shinx","Luxio","Luxray","Budew","Roserade","Cranidos","Rampardos","Shieldon","Bastiodon","Burmy","Wormadam","Mothim","Combee","Vespiquen","Pachirisu","Buizel","Floatzel","Cherubi","Cherrim","Shellos","Gastrodon","Ambipom","Drifloon","Drifblim","Buneary","Lopunny","Mismagius","Honchkrow","Glameow","Purugly","Chingling","Stunky","Skuntank","Bronzor","Bronzong","Bonsly","Mime Jr.","Happiny","Chatot","Spiritomb","Gible","Gabite","Garchomp","Munchlax","Riolu","Lucario","Hippopotas","Hippowdon","Skorupi","Drapion","Croagunk","Toxicroak","Carnivine","Finneon","Lumineon","Mantyke","Snover","Abomasnow","Weavile","Magnezone","Lickilicky","Rhyperior","Tangrowth","Electivire","Magmortar","Togekiss","Yanmega","Leafeon","Glaceon","Gliscor","Mamoswine","Porygon-Z","Gallade","Probopass","Dusknoir","Froslass","Rotom","Uxie","Mesprit","Azelf","Dialga","Palkia","Heatran","Regigigas","Giratina","Cresselia","Phione","Manaphy","Darkrai","Shaymin","Arceus","Victini","Snivy","Servine","Serperior","Tepig","Pignite","Emboar","Oshawott","Dewott","Samurott","Patrat","Watchog","Lillipup","Herdier","Stoutland","Purrloin","Liepard","Pansage","Simisage","Pansear","Simisear","Panpour","Simipour","Munna","Musharna","Pidove","Tranquill","Unfezant","Blitzle","Zebstrika","Roggenrola","Boldore","Gigalith","Woobat","Swoobat","Drilbur","Excadrill","Audino","Timburr","Gurdurr","Conkeldurr","Tympole","Palpitoad","Seismitoad","Throh","Sawk","Sewaddle","Swadloon","Leavanny","Venipede","Whirlipede","Scolipede","Cottonee","Whimsicott","Petilil","Lilligant","Basculin","Sandile","Krokorok","Krookodile","Darumaka","Darmanitan","Maractus","Dwebble","Crustle","Scraggy","Scrafty","Sigilyph","Yamask","Cofagrigus","Tirtouga","Carracosta","Archen","Archeops","Trubbish","Garbodor","Zorua","Zoroark","Minccino","Cinccino","Gothita","Gothorita","Gothitelle","Solosis","Duosion","Reuniclus","Ducklett","Swanna","Vanillite","Vanillish","Vanilluxe","Deerling","Sawsbuck","Emolga","Karrablast","Escavalier","Foongus","Amoonguss","Frillish","Jellicent","Alomomola","Joltik","Galvantula","Ferroseed","Ferrothorn","Klink","Klang","Klinklang","Tynamo","Eelektrik","Eelektross","Elgyem","Beheeyem","Litwick","Lampent","Chandelure","Axew","Fraxure","Haxorus","Cubchoo","Beartic","Cryogonal","Shelmet","Accelgor","Stunfisk","Mienfoo","Mienshao","Druddigon","Golett","Golurk","Pawniard","Bisharp","Bouffalant","Rufflet","Braviary","Vullaby","Mandibuzz","Heatmor","Durant","Deino","Zweilous","Hydreigon","Larvesta","Volcarona","Cobalion","Terrakion","Virizion","Tornadus","Thundurus","Reshiram","Zekrom","Landorus","Kyurem","Keldeo","Meloetta","Genesect","Chespin","Quilladin","Chesnaught","Fennekin","Braixen","Delphox","Froakie","Frogadier","Greninja","Bunnelby","Diggersby","Fletchling","Fletchinder","Talonflame","Scatterbug","Spewpa","Vivillon","Litleo","Pyroar","Flabébé","Floette","Florges","Skiddo","Gogoat","Pancham","Pangoro","Furfrou","Espurr","Meowstic","Honedge","Doublade","Aegislash","Spritzee","Aromatisse","Swirlix","Slurpuff","Inkay","Malamar","Binacle","Barbaracle","Skrelp","Dragalge","Clauncher","Clawitzer","Helioptile","Heliolisk","Tyrunt","Tyrantrum","Amaura","Aurorus","Sylveon","Hawlucha","Dedenne","Carbink","Goomy","Sliggoo","Goodra","Klefki","Phantump","Trevenant","Pumpkaboo","Gourgeist","Bergmite","Avalugg","Noibat","Noivern","Xerneas","Yveltal","Zygarde","Diancie","Hoopa","Volcanion","Rowlet","Dartrix","Decidueye","Litten","Torracat","Incineroar","Popplio","Brionne","Primarina","Pikipek","Trumbeak","Toucannon","Yungoos","Gumshoos","Grubbin","Charjabug","Vikavolt","Crabrawler","Crabominable","Oricorio","Cutiefly","Ribombee","Rockruff","Lycanroc","Wishiwashi","Mareanie","Toxapex","Mudbray","Mudsdale","Dewpider","Araquanid","Fomantis","Lurantis","Morelull","Shiinotic","Salandit","Salazzle","Stufful","Bewear","Bounsweet","Steenee","Tsareena","Comfey","Oranguru","Passimian","Wimpod","Golisopod","Sandygast","Palossand","Pyukumuku","Type: Null","Silvally","Minior","Komala","Turtonator","Togedemaru","Mimikyu","Bruxish","Drampa","Dhelmise","Jangmo-o","Hakamo-o","Kommo-o","Tapu Koko","Tapu Lele","Tapu Bulu","Tapu Fini","Cosmog","Cosmoem","Solgaleo","Lunala","Nihilego","Buzzwole","Pheromosa","Xurkitree","Celesteela","Kartana","Guzzlord","Necrozma","Magearna","Marshadow","Poipole","Naganadel","Stakataka","Blacephalon","Zeraora","Meltan","Melmetal","Grookey","Thwackey","Rillaboom","Scorbunny","Raboot","Cinderace","Sobble","Drizzile","Inteleon","Skwovet","Greedent","Rookidee","Corvisquire","Corviknight","Blipbug","Dottler","Orbeetle","Nickit","Thievul","Gossifleur","Eldegoss","Wooloo","Dubwool","Chewtle","Drednaw","Yamper","Boltund","Rolycoly","Carkol","Coalossal","Applin","Flapple","Appletun","Silicobra","Sandaconda","Cramorant","Arrokuda","Barraskewda","Toxel","Toxtricity","Sizzlipede","Centiskorch","Clobbopus","Grapploct","Sinistea","Polteageist","Hatenna","Hattrem","Hatterene","Impidimp","Morgrem","Grimmsnarl","Obstagoon","Perrserker","Cursola","Sirfetch'd","Mr. Rime","Runerigus","Milcery","Alcremie","Falinks","Pincurchin","Snom","Frosmoth","Stonjourner","Eiscue","Indeedee","Morpeko","Cufant","Copperajah","Dracozolt","Arctozolt","Dracovish","Arctovish","Duraludon","Dreepy","Drakloak","Dragapult","Zacian","Zamazenta","Eternatus","Kubfu","Urshifu","Zarude","Regieleki","Regidrago","Glastrier","Spectrier","Calyrex","Wyrdeer","Kleavor","Ursaluna","Basculegion","Sneasler","Overqwil","Enamorus","Sprigatito","Floragato","Meowscarada","Fuecoco","Crocalor","Skeledirge","Quaxly","Quaxwell","Quaquaval","Lechonk","Oinkologne","Tarountula","Spidops","Nymble","Lokix","Pawmi","Pawmo","Pawmot","Tandemaus","Maushold","Fidough","Dachsbun","Smoliv","Dolliv","Arboliva","Squawkabilly","Nacli","Naclstack","Garganacl","Charcadet","Armarouge","Ceruledge","Tadbulb","Bellibolt","Wattrel","Kilowattrel","Maschiff","Mabosstiff","Shroodle","Grafaiai","Bramblin","Brambleghast","Toedscool","Toedscruel","Klawf","Capsakid","Scovillain","Rellor","Rabsca","Flittle","Espathra","Tinkatink","Tinkatuff","Tinkaton","Wiglett","Wugtrio","Bombirdier","Finizen","Palafin","Varoom","Revavroom","Cyclizar","Orthworm","Glimmet","Glimmora","Greavard","Houndstone","Flamigo","Cetoddle","Cetitan","Veluza","Dondozo","Tatsugiri","Annihilape","Clodsire","Farigiraf","Dudunsparce","Kingambit","Great Tusk","Scream Tail","Brute Bonnet","Flutter Mane","Slither Wing","Sandy Shocks","Iron Treads","Iron Bundle","Iron Hands","Iron Jugulis","Iron Moth","Iron Thorns","Frigibax","Arctibax","Baxcalibur","Gimmighoul","Gholdengo","Wo-Chien","Chien-Pao","Ting-Lu","Chi-Yu","Roaring Moon","Iron Valiant","Koraidon","Miraidon","Walking Wake","Iron Leaves","Dipplin","Poltchageist","Sinistcha","Okidogi","Mankidori","Fezandipiti","Ogerpon","Archaludon","Hydrapple","Gouging Fire","Raging Bolt","Iron Boulder","Iron Crown","Terapagos","Pecharunt"]},{}],255:[function(e,t,r){"use strict";const i=e("unique-random-array"),n=e("./data/en.json"),a="https://github.com/sindresorhus/pokemon",s=`Please report to ${a}/issues if we missed something.`,o=new Set(["de","en","fr","es","ja","ko","ru","th","zh-Hans","zh-Hant"]),c=new Map;function d(t="en"){if("en"===t)return n;if(!o.has(t))throw new Error(`Localized list for language code '${t}' does not exist. Pull request welcome: ${a}`);return e(`./data/${t.toLowerCase()}.json`)}r.all=d,r.random=(e="en")=>{if(c.has(e))return c.get(e)();const t=d(e),r=i(t);return c.set(e,r),r()},r.getName=(e,t="en")=>{const r=d(t)[e-1];if(!r)throw new Error(`Pokémon with ID '${e}' does not exist. ${s}`);return r},r.getId=(e,t="en")=>{const r=d(t).indexOf(e);if(-1===r)throw new Error(`Pokémon with name '${e}' does not exist for language code '${t}'. ${s}`);return r+1},r.languages=o},{"./data/en.json":254,"unique-random-array":310}],256:[function(e,t,r){(function(e){(function(){"use strict";void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:function(t,r,i,n){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var a,s,o=arguments.length;switch(o){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,r)}));case 3:return e.nextTick((function(){t.call(null,r,i)}));case 4:return e.nextTick((function(){t.call(null,r,i,n)}));default:for(a=new Array(o-1),s=0;s<a.length;)a[s++]=arguments[s];return e.nextTick((function(){t.apply(null,a)}))}}}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:257}],257:[function(e,t,r){var i,n,a=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function c(e){if(i===setTimeout)return setTimeout(e,0);if((i===s||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:s}catch(e){i=s}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(e){n=o}}();var d,u=[],l=!1,h=-1;function f(){l&&d&&(l=!1,d.length?u=d.concat(u):h=-1,u.length&&p())}function p(){if(!l){var e=c(f);l=!0;for(var t=u.length;t;){for(d=u,u=[];++h<t;)d&&d[h].run();h=-1,t=u.length}d=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{return n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function b(){}a.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];u.push(new m(e,t)),1!==u.length||l||c(p)},m.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=b,a.addListener=b,a.once=b,a.off=b,a.removeListener=b,a.removeAllListeners=b,a.emit=b,a.prependListener=b,a.prependOnceListener=b,a.listeners=function(e){return[]},a.binding=function(e){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},{}],258:[function(e,t,r){r.publicEncrypt=e("./publicEncrypt"),r.privateDecrypt=e("./privateDecrypt"),r.privateEncrypt=function(e,t){return r.publicEncrypt(e,t,!0)},r.publicDecrypt=function(e,t){return r.privateDecrypt(e,t,!0)}},{"./privateDecrypt":261,"./publicEncrypt":262}],259:[function(e,t,r){var i=e("create-hash"),n=e("safe-buffer").Buffer;function a(e){var t=n.allocUnsafe(4);return t.writeUInt32BE(e,0),t}t.exports=function(e,t){for(var r,s=n.alloc(0),o=0;s.length<t;)r=a(o++),s=n.concat([s,i("sha1").update(e).update(r).digest()]);return s.slice(0,t)}},{"create-hash":99,"safe-buffer":284}],260:[function(e,t,r){arguments[4][55][0].apply(r,arguments)},{buffer:63,dup:55}],261:[function(e,t,r){var i=e("parse-asn1"),n=e("./mgf"),a=e("./xor"),s=e("bn.js"),o=e("browserify-rsa"),c=e("create-hash"),d=e("./withPublic"),u=e("safe-buffer").Buffer;t.exports=function(e,t,r){var l;l=e.padding?e.padding:r?1:4;var h,f=i(e),p=f.modulus.byteLength();if(t.length>p||new s(t).cmp(f.modulus)>=0)throw new Error("decryption error");h=r?d(new s(t),f):o(t,f);var m=u.alloc(p-h.length);if(h=u.concat([m,h],p),4===l)return function(e,t){var r=e.modulus.byteLength(),i=c("sha1").update(u.alloc(0)).digest(),s=i.length;if(0!==t[0])throw new Error("decryption error");var o=t.slice(1,s+1),d=t.slice(s+1),l=a(o,n(d,s)),h=a(d,n(l,r-s-1));if(function(e,t){e=u.from(e),t=u.from(t);var r=0,i=e.length;e.length!==t.length&&(r++,i=Math.min(e.length,t.length));var n=-1;for(;++n<i;)r+=e[n]^t[n];return r}(i,h.slice(0,s)))throw new Error("decryption error");var f=s;for(;0===h[f];)f++;if(1!==h[f++])throw new Error("decryption error");return h.slice(f)}(f,h);if(1===l)return function(e,t,r){var i=t.slice(0,2),n=2,a=0;for(;0!==t[n++];)if(n>=t.length){a++;break}var s=t.slice(2,n-1);("0002"!==i.toString("hex")&&!r||"0001"!==i.toString("hex")&&r)&&a++;s.length<8&&a++;if(a)throw new Error("decryption error");return t.slice(n)}(0,h,r);if(3===l)return h;throw new Error("unknown padding")}},{"./mgf":259,"./withPublic":263,"./xor":264,"bn.js":260,"browserify-rsa":84,"create-hash":99,"parse-asn1":247,"safe-buffer":284}],262:[function(e,t,r){var i=e("parse-asn1"),n=e("randombytes"),a=e("create-hash"),s=e("./mgf"),o=e("./xor"),c=e("bn.js"),d=e("./withPublic"),u=e("browserify-rsa"),l=e("safe-buffer").Buffer;t.exports=function(e,t,r){var h;h=e.padding?e.padding:r?1:4;var f,p=i(e);if(4===h)f=function(e,t){var r=e.modulus.byteLength(),i=t.length,d=a("sha1").update(l.alloc(0)).digest(),u=d.length,h=2*u;if(i>r-h-2)throw new Error("message too long");var f=l.alloc(r-i-h-2),p=r-u-1,m=n(u),b=o(l.concat([d,f,l.alloc(1,1),t],p),s(m,p)),g=o(m,s(b,u));return new c(l.concat([l.alloc(1),g,b],r))}(p,t);else if(1===h)f=function(e,t,r){var i,a=t.length,s=e.modulus.byteLength();if(a>s-11)throw new Error("message too long");i=r?l.alloc(s-a-3,255):function(e){var t,r=l.allocUnsafe(e),i=0,a=n(2*e),s=0;for(;i<e;)s===a.length&&(a=n(2*e),s=0),(t=a[s++])&&(r[i++]=t);return r}(s-a-3);return new c(l.concat([l.from([0,r?1:2]),i,l.alloc(1),t],s))}(p,t,r);else{if(3!==h)throw new Error("unknown padding");if((f=new c(t)).cmp(p.modulus)>=0)throw new Error("data too long for modulus")}return r?u(f,p):d(f,p)}},{"./mgf":259,"./withPublic":263,"./xor":264,"bn.js":260,"browserify-rsa":84,"create-hash":99,"parse-asn1":247,randombytes:266,"safe-buffer":284}],263:[function(e,t,r){var i=e("bn.js"),n=e("safe-buffer").Buffer;t.exports=function(e,t){return n.from(e.toRed(i.mont(t.modulus)).redPow(new i(t.publicExponent)).fromRed().toArray())}},{"bn.js":260,"safe-buffer":284}],264:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,i=-1;++i<r;)e[i]^=t[i];return e}},{}],265:[function(e,t,r){(function(e){(function(){
|
|
25
|
-
/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
26
|
-
let r;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:e):e=>(r||(r=Promise.resolve())).then(e).catch((e=>setTimeout((()=>{throw e}),0)))}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],266:[function(e,t,r){(function(r,i){(function(){"use strict";var n=65536,a=4294967295;var s=e("safe-buffer").Buffer,o=i.crypto||i.msCrypto;o&&o.getRandomValues?t.exports=function(e,t){if(e>a)throw new RangeError("requested too many random bytes");var i=s.allocUnsafe(e);if(e>0)if(e>n)for(var c=0;c<e;c+=n)o.getRandomValues(i.slice(c,c+n));else o.getRandomValues(i);if("function"==typeof t)return r.nextTick((function(){t(null,i)}));return i}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,"safe-buffer":284}],267:[function(e,t,r){(function(t,i){(function(){"use strict";function n(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var a=e("safe-buffer"),s=e("randombytes"),o=a.Buffer,c=a.kMaxLength,d=i.crypto||i.msCrypto,u=Math.pow(2,32)-1;function l(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>u||e<0)throw new TypeError("offset must be a uint32");if(e>c||e>t)throw new RangeError("offset out of range")}function h(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>u||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>c)throw new RangeError("buffer too small")}function f(e,r,i,n){if(t.browser){var a=e.buffer,o=new Uint8Array(a,r,i);return d.getRandomValues(o),n?void t.nextTick((function(){n(null,e)})):e}if(!n)return s(i).copy(e,r),e;s(i,(function(t,i){if(t)return n(t);i.copy(e,r),n(null,e)}))}d&&d.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,n){if(!(o.isBuffer(e)||e instanceof i.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)n=t,t=0,r=e.length;else if("function"==typeof r)n=r,r=e.length-t;else if("function"!=typeof n)throw new TypeError('"cb" argument must be a function');return l(t,e.length),h(r,t,e.length),f(e,t,r,n)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(o.isBuffer(e)||e instanceof i.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');l(t,e.length),void 0===r&&(r=e.length-t);return h(r,t,e.length),f(e,t,r)}):(r.randomFill=n,r.randomFillSync=n)}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:257,randombytes:266,"safe-buffer":284}],268:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":269}],269:[function(e,t,r){"use strict";var i=e("process-nextick-args"),n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=l;var a=Object.create(e("core-util-is"));a.inherits=e("inherits");var s=e("./_stream_readable"),o=e("./_stream_writable");a.inherits(l,s);for(var c=n(o.prototype),d=0;d<c.length;d++){var u=c[d];l.prototype[u]||(l.prototype[u]=o.prototype[u])}function l(e){if(!(this instanceof l))return new l(e);s.call(this,e),o.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",h)}function h(){this.allowHalfOpen||this._writableState.ended||i.nextTick(f,this)}function f(e){e.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"destroyed",{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)}}),l.prototype._destroy=function(e,t){this.push(null),this.end(),i.nextTick(t,e)}},{"./_stream_readable":271,"./_stream_writable":273,"core-util-is":96,inherits:174,"process-nextick-args":256}],270:[function(e,t,r){"use strict";t.exports=a;var i=e("./_stream_transform"),n=Object.create(e("core-util-is"));function a(e){if(!(this instanceof a))return new a(e);i.call(this,e)}n.inherits=e("inherits"),n.inherits(a,i),a.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":272,"core-util-is":96,inherits:174}],271:[function(e,t,r){(function(r,i){(function(){"use strict";var n=e("process-nextick-args");t.exports=y;var a,s=e("isarray");y.ReadableState=v;e("events").EventEmitter;var o=function(e,t){return e.listeners(t).length},c=e("./internal/streams/stream"),d=e("safe-buffer").Buffer,u=(void 0!==i?i:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var l=Object.create(e("core-util-is"));l.inherits=e("inherits");var h=e("util"),f=void 0;f=h&&h.debuglog?h.debuglog("stream"):function(){};var p,m=e("./internal/streams/BufferList"),b=e("./internal/streams/destroy");l.inherits(y,c);var g=["error","close","destroy","pause","resume"];function v(t,r){t=t||{};var i=r instanceof(a=a||e("./_stream_duplex"));this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var n=t.highWaterMark,s=t.readableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:i&&(s||0===s)?s:o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,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.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(p||(p=e("string_decoder/").StringDecoder),this.decoder=new p(t.encoding),this.encoding=t.encoding)}function y(t){if(a=a||e("./_stream_duplex"),!(this instanceof y))return new y(t);this._readableState=new v(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),c.call(this)}function _(e,t,r,i,n){var a,s=e._readableState;null===t?(s.reading=!1,function(e,t){if(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,R(e)}(e,s)):(n||(a=function(e,t){var r;i=t,d.isBuffer(i)||i instanceof u||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var i;return r}(s,t)),a?e.emit("error",a):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===d.prototype||(t=function(e){return d.from(e)}(t)),i?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):w(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?w(e,s,t,!1):M(e,s)):w(e,s,t,!1))):i||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(s)}function w(e,t,r,i){t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&R(e)),M(e,t)}Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),y.prototype.destroy=b.destroy,y.prototype._undestroy=b.undestroy,y.prototype._destroy=function(e,t){this.push(null),t(e)},y.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=d.from(e,t),t=""),r=!0),_(this,e,t,!1,r)},y.prototype.unshift=function(e){return _(this,e,null,!0,!1)},y.prototype.isPaused=function(){return!1===this._readableState.flowing},y.prototype.setEncoding=function(t){return p||(p=e("string_decoder/").StringDecoder),this._readableState.decoder=new p(t),this._readableState.encoding=t,this};var S=8388608;function k(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>=S?e=S:(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;t.needReadable=!1,t.emittedReadable||(f("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?n.nextTick(P,e):P(e))}function P(e){f("emit readable"),e.emit("readable"),C(e)}function M(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(E,e,t))}function E(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(f("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}function x(e){f("readable nexttick read 0"),e.read(0)}function T(e,t){t.reading||(f("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),C(e),t.flowing&&!t.reading&&e.read(0)}function C(e){var t=e._readableState;for(f("flow",t.flowing);t.flowing&&null!==e.read(););}function I(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.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var i;e<t.head.data.length?(i=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):i=e===t.head.data.length?t.shift():r?function(e,t){var r=t.head,i=1,n=r.data;e-=n.length;for(;r=r.next;){var a=r.data,s=e>a.length?a.length:e;if(s===a.length?n+=a:n+=a.slice(0,e),0===(e-=s)){s===a.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(s));break}++i}return t.length-=i,n}(e,t):function(e,t){var r=d.allocUnsafe(e),i=t.head,n=1;i.data.copy(r),e-=i.data.length;for(;i=i.next;){var a=i.data,s=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,s),0===(e-=s)){s===a.length?(++n,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=a.slice(s));break}++n}return t.length-=n,r}(e,t);return i}(e,t.buffer,t.decoder),r);var r}function D(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,n.nextTick(O,t,e))}function O(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function A(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}y.prototype.read=function(e){f("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return f("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?D(this):R(this),null;if(0===(e=k(e,t))&&t.ended)return 0===t.length&&D(this),null;var i,n=t.needReadable;return f("need readable",n),(0===t.length||t.length-e<t.highWaterMark)&&f("length less than watermark",n=!0),t.ended||t.reading?f("reading or ended",n=!1):n&&(f("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=k(r,t))),null===(i=e>0?I(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&D(this)),null!==i&&this.emit("data",i),i},y.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},y.prototype.pipe=function(e,t){var i=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=e;break;case 1:a.pipes=[a.pipes,e];break;default:a.pipes.push(e)}a.pipesCount+=1,f("pipe count=%d opts=%j",a.pipesCount,t);var c=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?u:y;function d(t,r){f("onunpipe"),t===i&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,f("cleanup"),e.removeListener("close",g),e.removeListener("finish",v),e.removeListener("drain",l),e.removeListener("error",b),e.removeListener("unpipe",d),i.removeListener("end",u),i.removeListener("end",y),i.removeListener("data",m),h=!0,!a.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function u(){f("onend"),e.end()}a.endEmitted?n.nextTick(c):i.once("end",c),e.on("unpipe",d);var l=function(e){return function(){var t=e._readableState;f("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,C(e))}}(i);e.on("drain",l);var h=!1;var p=!1;function m(t){f("ondata"),p=!1,!1!==e.write(t)||p||((1===a.pipesCount&&a.pipes===e||a.pipesCount>1&&-1!==A(a.pipes,e))&&!h&&(f("false write response, pause",a.awaitDrain),a.awaitDrain++,p=!0),i.pause())}function b(t){f("onerror",t),y(),e.removeListener("error",b),0===o(e,"error")&&e.emit("error",t)}function g(){e.removeListener("finish",v),y()}function v(){f("onfinish"),e.removeListener("close",g),y()}function y(){f("unpipe"),i.unpipe(e)}return i.on("data",m),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",b),e.once("close",g),e.once("finish",v),e.emit("pipe",i),a.flowing||(f("pipe resume"),i.resume()),e},y.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 a=0;a<n;a++)i[a].emit("unpipe",this,{hasUnpiped:!1});return this}var s=A(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},y.prototype.on=function(e,t){var r=c.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var i=this._readableState;i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&R(this):n.nextTick(x,this))}return r},y.prototype.addListener=y.prototype.on,y.prototype.resume=function(){var e=this._readableState;return e.flowing||(f("resume"),e.flowing=!0,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(T,e,t))}(this,e)),this},y.prototype.pause=function(){return f("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(f("pause"),this._readableState.flowing=!1,this.emit("pause")),this},y.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;for(var n in e.on("end",(function(){if(f("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){(f("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 a=0;a<g.length;a++)e.on(g[a],this.emit.bind(this,g[a]));return this._read=function(t){f("wrapped _read",t),i&&(i=!1,e.resume())},this},Object.defineProperty(y.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),y._fromList=I}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":269,"./internal/streams/BufferList":274,"./internal/streams/destroy":275,"./internal/streams/stream":276,_process:257,"core-util-is":96,events:91,inherits:174,isarray:176,"process-nextick-args":256,"safe-buffer":277,"string_decoder/":278,util:63}],272:[function(e,t,r){"use strict";t.exports=s;var i=e("./_stream_duplex"),n=Object.create(e("core-util-is"));function a(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(!i)return this.emit("error",new Error("write callback called multiple times"));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 s(e){if(!(this instanceof s))return new s(e);i.call(this,e),this._transformState={afterTransform:a.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",o)}function o(){var e=this;"function"==typeof this._flush?this._flush((function(t,r){c(e,t,r)})):c(this,null,null)}function c(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}n.inherits=e("inherits"),n.inherits(s,i),s.prototype.push=function(e,t){return this._transformState.needTransform=!1,i.prototype.push.call(this,e,t)},s.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")},s.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)}},s.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},s.prototype._destroy=function(e,t){var r=this;i.prototype._destroy.call(this,e,(function(e){t(e),r.emit("close")}))}},{"./_stream_duplex":269,"core-util-is":96,inherits:174}],273:[function(e,t,r){(function(r,i,n){(function(){"use strict";var a=e("process-nextick-args");function s(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)}}t.exports=v;var o,c=!r.browser&&["v0.10","v0.9."].indexOf(r.version.slice(0,5))>-1?n:a.nextTick;v.WritableState=g;var d=Object.create(e("core-util-is"));d.inherits=e("inherits");var u={deprecate:e("util-deprecate")},l=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,f=(void 0!==i?i:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var p,m=e("./internal/streams/destroy");function b(){}function g(t,r){o=o||e("./_stream_duplex"),t=t||{};var i=r instanceof o;this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var n=t.highWaterMark,d=t.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:i&&(d||0===d)?d:u,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===t.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=t.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,n=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,i,n){--t.pendingcb,r?(a.nextTick(n,i),a.nextTick(R,e,t),e._writableState.errorEmitted=!0,e.emit("error",i)):(n(i),e._writableState.errorEmitted=!0,e.emit("error",i),R(e,t))}(e,r,i,t,n);else{var s=S(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),i?c(_,e,r,s,n):_(e,r,s,n)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function v(t){if(o=o||e("./_stream_duplex"),!(p.call(v,this)||this instanceof o))return new v(t);this._writableState=new g(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),l.call(this)}function y(e,t,r,i,n,a,s){t.writelen=i,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(n,t.onwrite):e._write(n,a,t.onwrite),t.sync=!1}function _(e,t,r,i){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,i(),R(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),a=t.corkedRequestsFree;a.entry=r;for(var o=0,c=!0;r;)n[o]=r,r.isBuf||(c=!1),r=r.next,o+=1;n.allBuffers=c,y(e,t,!0,t.length,n,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var d=r.chunk,u=r.encoding,l=r.callback;if(y(e,t,!1,t.objectMode?1:d.length,d,u,l),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function S(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function k(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),R(e,t)}))}function R(e,t){var r=S(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,a.nextTick(k,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}d.inherits(v,l),g.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(g.prototype,"buffer",{get:u.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]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(v,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===v&&(e&&e._writableState instanceof g)}})):p=function(e){return e instanceof this},v.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},v.prototype.write=function(e,t,r){var i,n=this._writableState,s=!1,o=!n.objectMode&&(i=e,h.isBuffer(i)||i instanceof f);return o&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),"function"!=typeof r&&(r=b),n.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),a.nextTick(t,r)}(this,r):(o||function(e,t,r,i){var n=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),a.nextTick(i,s),n=!1),n}(this,n,e,r))&&(n.pendingcb++,s=function(e,t,r,i,n,a){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,i,n);i!==s&&(r=!0,n="buffer",i=s)}var o=t.objectMode?1:i.length;t.length+=o;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var d=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:a,next:null},d?d.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else y(e,t,!1,o,i,n,a);return c}(this,n,o,e,t,r)),s},v.prototype.cork=function(){this._writableState.corked++},v.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||w(this,e))},v.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 TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(v.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),v.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},v.prototype._writev=null,v.prototype.end=function(e,t,r){var i=this._writableState;"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,R(e,t),r&&(t.finished?a.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r)},Object.defineProperty(v.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),v.prototype.destroy=m.destroy,v.prototype._undestroy=m.undestroy,v.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("timers").setImmediate)},{"./_stream_duplex":269,"./internal/streams/destroy":275,"./internal/streams/stream":276,_process:257,"core-util-is":96,inherits:174,"process-nextick-args":256,"safe-buffer":277,timers:308,"util-deprecate":312}],274:[function(e,t,r){"use strict";var i=e("safe-buffer").Buffer,n=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return i.alloc(0);for(var t,r,n,a=i.allocUnsafe(e>>>0),s=this.head,o=0;s;)t=s.data,r=a,n=o,t.copy(r,n),o+=s.data.length,s=s.next;return a},e}(),n&&n.inspect&&n.inspect.custom&&(t.exports.prototype[n.inspect.custom]=function(){var e=n.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":277,util:63}],275:[function(e,t,r){"use strict";var i=e("process-nextick-args");function n(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,a=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return a||s?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(n,this,e)):i.nextTick(n,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||(r._writableState.errorEmitted=!0,i.nextTick(n,r,e)):i.nextTick(n,r,e):t&&t(e)})),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)}}},{"process-nextick-args":256}],276:[function(e,t,r){t.exports=e("events").EventEmitter},{events:91}],277:[function(e,t,r){var i=e("buffer"),n=i.Buffer;function a(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?t.exports=i:(a(i,r),r.Buffer=s),a(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)}},{buffer:94}],278:[function(e,t,r){"use strict";var i=e("safe-buffer").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 a(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=d,t=4;break;case"utf8":this.fillLast=o,t=4;break;case"base64":this.text=u,this.end=l,t=3;break;default:return this.write=h,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 o(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 d(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 u(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 l(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function f(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.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||""},a.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},a.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)},a.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}},{"safe-buffer":277}],279:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":280}],280:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":269,"./lib/_stream_passthrough.js":270,"./lib/_stream_readable.js":271,"./lib/_stream_transform.js":272,"./lib/_stream_writable.js":273}],281:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":280}],282:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":273}],283:[function(e,t,r){"use strict";var i=e("buffer").Buffer,n=e("inherits"),a=e("hash-base"),s=new Array(16),o=[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=[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],d=[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],u=[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],l=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function f(){a.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function p(e,t){return e<<t|e>>>32-t}function m(e,t,r,i,n,a,s,o){return p(e+(t^r^i)+a+s|0,o)+n|0}function b(e,t,r,i,n,a,s,o){return p(e+(t&r|~t&i)+a+s|0,o)+n|0}function g(e,t,r,i,n,a,s,o){return p(e+((t|~r)^i)+a+s|0,o)+n|0}function v(e,t,r,i,n,a,s,o){return p(e+(t&i|r&~i)+a+s|0,o)+n|0}function y(e,t,r,i,n,a,s,o){return p(e+(t^(r|~i))+a+s|0,o)+n|0}n(f,a),f.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,i=0|this._b,n=0|this._c,a=0|this._d,f=0|this._e,_=0|this._a,w=0|this._b,S=0|this._c,k=0|this._d,R=0|this._e,P=0;P<80;P+=1){var M,E;P<16?(M=m(r,i,n,a,f,e[o[P]],l[0],d[P]),E=y(_,w,S,k,R,e[c[P]],h[0],u[P])):P<32?(M=b(r,i,n,a,f,e[o[P]],l[1],d[P]),E=v(_,w,S,k,R,e[c[P]],h[1],u[P])):P<48?(M=g(r,i,n,a,f,e[o[P]],l[2],d[P]),E=g(_,w,S,k,R,e[c[P]],h[2],u[P])):P<64?(M=v(r,i,n,a,f,e[o[P]],l[3],d[P]),E=b(_,w,S,k,R,e[c[P]],h[3],u[P])):(M=y(r,i,n,a,f,e[o[P]],l[4],d[P]),E=m(_,w,S,k,R,e[c[P]],h[4],u[P])),r=f,f=a,a=p(n,10),n=i,i=M,_=R,R=k,k=p(S,10),S=w,w=E}var x=this._b+n+k|0;this._b=this._c+a+R|0,this._c=this._d+f+_|0,this._d=this._e+r+w|0,this._e=this._a+i+S|0,this._a=x},f.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=i.alloc?i.alloc(20):new i(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=f},{buffer:94,"hash-base":159,inherits:174}],284:[function(e,t,r){
|
|
27
|
-
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
28
|
-
var i=e("buffer"),n=i.Buffer;function a(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?t.exports=i:(a(i,r),r.Buffer=s),s.prototype=Object.create(n.prototype),a(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)}},{buffer:94}],285:[function(e,t,r){var i=t.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(i).forEach((function(e){i[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))},{}],286:[function(e,t,r){var i=e("./parser"),n=e("./writer");r.write=n,r.parse=i.parse,r.parseParams=i.parseParams,r.parseFmtpConfig=i.parseFmtpConfig,r.parsePayloads=i.parsePayloads,r.parseRemoteCandidates=i.parseRemoteCandidates,r.parseImageAttributes=i.parseImageAttributes,r.parseSimulcastStreamList=i.parseSimulcastStreamList},{"./parser":287,"./writer":288}],287:[function(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 a=e.push?{}:n?t[e.name]:t;!function(e,t,r,n){if(n&&!r)t[n]=i(e[1]);else for(var a=0;a<r.length;a+=1)null!=e[a+1]&&(t[r[a]]=i(e[a+1]))}(r.match(e.reg),a,e.names,e.name),e.push&&t[e.push].push(a)},a=e("./grammar"),s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);r.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 o=0;o<(a[t]||[]).length;o+=1){var c=a[t][o];if(c.reg.test(s))return n(c,i,s)}})),t.media=r,t};var o=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};r.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},r.parseFmtpConfig=r.parseParams,r.parsePayloads=function(e){return e.toString().split(" ").map(Number)},r.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},r.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},r.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}}))}))}},{"./grammar":285}],288:[function(e,t,r){var i=e("./grammar"),n=/%[sdv%]/g,a=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 a.apply(null,i)},o=["v","o","s","i","u","e","p","c","b","t","r","z","a"],c=["i","c","b","a"];t.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||o,n=t.innerOrder||c,a=[];return r.forEach((function(t){i[t].forEach((function(r){r.name in e&&null!=e[r.name]?a.push(s(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){a.push(s(t,r,e))}))}))})),e.media.forEach((function(e){a.push(s("m",i.m[0],e)),n.forEach((function(t){i[t].forEach((function(r){r.name in e&&null!=e[r.name]?a.push(s(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){a.push(s(t,r,e))}))}))}))})),a.join("\r\n")+"\r\n"}},{"./grammar":285}],289:[function(e,t,r){var i=e("safe-buffer").Buffer;function n(e,t){this._block=i.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}n.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=i.from(e,t));for(var r=this._block,n=this._blockSize,a=e.length,s=this._len,o=0;o<a;){for(var c=s%n,d=Math.min(a-o,n-c),u=0;u<d;u++)r[c+u]=e[o+u];o+=d,(s+=d)%n==0&&this._update(r)}return this._len+=a,this},n.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(4294967295&r)>>>0,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var a=this._hash();return e?a.toString(e):a},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=n},{"safe-buffer":284}],290:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":291,"./sha1":292,"./sha224":293,"./sha256":294,"./sha384":295,"./sha512":296}],291:[function(e,t,r){var i=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1518500249,1859775393,-1894007588,-899497514],o=new Array(80);function c(){this.init(),this._w=o,n.call(this,64,56)}function d(e){return e<<30|e>>>2}function u(e,t,r,i){return 0===e?t&r|~t&i:2===e?t&r|t&i|r&i:t^r^i}i(c,n),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(e){for(var t,r=this._w,i=0|this._a,n=0|this._b,a=0|this._c,o=0|this._d,c=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=r[l-3]^r[l-8]^r[l-14]^r[l-16];for(var h=0;h<80;++h){var f=~~(h/20),p=0|((t=i)<<5|t>>>27)+u(f,n,a,o)+c+r[h]+s[f];c=o,o=a,a=d(n),n=i,i=p}this._a=i+this._a|0,this._b=n+this._b|0,this._c=a+this._c|0,this._d=o+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var e=a.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=c},{"./hash":289,inherits:174,"safe-buffer":284}],292:[function(e,t,r){var i=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1518500249,1859775393,-1894007588,-899497514],o=new Array(80);function c(){this.init(),this._w=o,n.call(this,64,56)}function d(e){return e<<5|e>>>27}function u(e){return e<<30|e>>>2}function l(e,t,r,i){return 0===e?t&r|~t&i:2===e?t&r|t&i|r&i:t^r^i}i(c,n),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(e){for(var t,r=this._w,i=0|this._a,n=0|this._b,a=0|this._c,o=0|this._d,c=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=(t=r[h-3]^r[h-8]^r[h-14]^r[h-16])<<1|t>>>31;for(var f=0;f<80;++f){var p=~~(f/20),m=d(i)+l(p,n,a,o)+c+r[f]+s[p]|0;c=o,o=a,a=u(n),n=i,i=m}this._a=i+this._a|0,this._b=n+this._b|0,this._c=a+this._c|0,this._d=o+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var e=a.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=c},{"./hash":289,inherits:174,"safe-buffer":284}],293:[function(e,t,r){var i=e("inherits"),n=e("./sha256"),a=e("./hash"),s=e("safe-buffer").Buffer,o=new Array(64);function c(){this.init(),this._w=o,a.call(this,64,56)}i(c,n),c.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},c.prototype._hash=function(){var e=s.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=c},{"./hash":289,"./sha256":294,inherits:174,"safe-buffer":284}],294:[function(e,t,r){var i=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],o=new Array(64);function c(){this.init(),this._w=o,n.call(this,64,56)}function d(e,t,r){return r^e&(t^r)}function u(e,t,r){return e&t|r&(e|t)}function l(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function h(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function f(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}i(c,n),c.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},c.prototype._update=function(e){for(var t,r=this._w,i=0|this._a,n=0|this._b,a=0|this._c,o=0|this._d,c=0|this._e,p=0|this._f,m=0|this._g,b=0|this._h,g=0;g<16;++g)r[g]=e.readInt32BE(4*g);for(;g<64;++g)r[g]=0|(((t=r[g-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[g-7]+f(r[g-15])+r[g-16];for(var v=0;v<64;++v){var y=b+h(c)+d(c,p,m)+s[v]+r[v]|0,_=l(i)+u(i,n,a)|0;b=m,m=p,p=c,c=o+y|0,o=a,a=n,n=i,i=y+_|0}this._a=i+this._a|0,this._b=n+this._b|0,this._c=a+this._c|0,this._d=o+this._d|0,this._e=c+this._e|0,this._f=p+this._f|0,this._g=m+this._g|0,this._h=b+this._h|0},c.prototype._hash=function(){var e=a.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=c},{"./hash":289,inherits:174,"safe-buffer":284}],295:[function(e,t,r){var i=e("inherits"),n=e("./sha512"),a=e("./hash"),s=e("safe-buffer").Buffer,o=new Array(160);function c(){this.init(),this._w=o,a.call(this,128,112)}i(c,n),c.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},c.prototype._hash=function(){var e=s.allocUnsafe(48);function t(t,r,i){e.writeInt32BE(t,i),e.writeInt32BE(r,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=c},{"./hash":289,"./sha512":296,inherits:174,"safe-buffer":284}],296:[function(e,t,r){var i=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],o=new Array(160);function c(){this.init(),this._w=o,n.call(this,128,112)}function d(e,t,r){return r^e&(t^r)}function u(e,t,r){return e&t|r&(e|t)}function l(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function h(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function f(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function m(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function g(e,t){return e>>>0<t>>>0?1:0}i(c,n),c.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},c.prototype._update=function(e){for(var t=this._w,r=0|this._ah,i=0|this._bh,n=0|this._ch,a=0|this._dh,o=0|this._eh,c=0|this._fh,v=0|this._gh,y=0|this._hh,_=0|this._al,w=0|this._bl,S=0|this._cl,k=0|this._dl,R=0|this._el,P=0|this._fl,M=0|this._gl,E=0|this._hl,x=0;x<32;x+=2)t[x]=e.readInt32BE(4*x),t[x+1]=e.readInt32BE(4*x+4);for(;x<160;x+=2){var T=t[x-30],C=t[x-30+1],I=f(T,C),D=p(C,T),O=m(T=t[x-4],C=t[x-4+1]),A=b(C,T),L=t[x-14],j=t[x-14+1],B=t[x-32],N=t[x-32+1],F=D+j|0,U=I+L+g(F,D)|0;U=(U=U+O+g(F=F+A|0,A)|0)+B+g(F=F+N|0,N)|0,t[x]=U,t[x+1]=F}for(var q=0;q<160;q+=2){U=t[q],F=t[q+1];var z=u(r,i,n),V=u(_,w,S),G=l(r,_),W=l(_,r),H=h(o,R),K=h(R,o),$=s[q],J=s[q+1],Y=d(o,c,v),X=d(R,P,M),Z=E+K|0,Q=y+H+g(Z,E)|0;Q=(Q=(Q=Q+Y+g(Z=Z+X|0,X)|0)+$+g(Z=Z+J|0,J)|0)+U+g(Z=Z+F|0,F)|0;var ee=W+V|0,te=G+z+g(ee,W)|0;y=v,E=M,v=c,M=P,c=o,P=R,o=a+Q+g(R=k+Z|0,k)|0,a=n,k=S,n=i,S=w,i=r,w=_,r=Q+te+g(_=Z+ee|0,Z)|0}this._al=this._al+_|0,this._bl=this._bl+w|0,this._cl=this._cl+S|0,this._dl=this._dl+k|0,this._el=this._el+R|0,this._fl=this._fl+P|0,this._gl=this._gl+M|0,this._hl=this._hl+E|0,this._ah=this._ah+r+g(this._al,_)|0,this._bh=this._bh+i+g(this._bl,w)|0,this._ch=this._ch+n+g(this._cl,S)|0,this._dh=this._dh+a+g(this._dl,k)|0,this._eh=this._eh+o+g(this._el,R)|0,this._fh=this._fh+c+g(this._fl,P)|0,this._gh=this._gh+v+g(this._gl,M)|0,this._hh=this._hh+y+g(this._hl,E)|0},c.prototype._hash=function(){var e=a.allocUnsafe(64);function t(t,r,i){e.writeInt32BE(t,i),e.writeInt32BE(r,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=c},{"./hash":289,inherits:174,"safe-buffer":284}],297:[function(e,t,r){"use strict";function i(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Object.defineProperty(r,"__esModule",{value:!0}),r.Backoff=void 0,r.Backoff=i,i.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+r:e-r}return 0|Math.min(e,this.max)},i.prototype.reset=function(){this.attempts=0},i.prototype.setMin=function(e){this.ms=e},i.prototype.setMax=function(e){this.max=e},i.prototype.setJitter=function(e){this.jitter=e}},{}],298:[function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.connect=r.io=r.Socket=r.Manager=r.protocol=void 0;const n=e("./url.js"),a=e("./manager.js");Object.defineProperty(r,"Manager",{enumerable:!0,get:function(){return a.Manager}});const s=e("./socket.js");Object.defineProperty(r,"Socket",{enumerable:!0,get:function(){return s.Socket}});const o=i(e("debug")).default("socket.io-client"),c={};function d(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const r=n.url(e,t.path||"/socket.io"),i=r.source,s=r.id,d=r.path,u=c[s]&&d in c[s].nsps;let l;return t.forceNew||t["force new connection"]||!1===t.multiplex||u?(o("ignoring socket cache for %s",i),l=new a.Manager(i,t)):(c[s]||(o("new io instance for %s",i),c[s]=new a.Manager(i,t)),l=c[s]),r.query&&!t.query&&(t.query=r.queryKey),l.socket(r.path,t)}r.io=d,r.connect=d,r.default=d,Object.assign(d,{Manager:a.Manager,Socket:s.Socket,io:d,connect:d});var u=e("socket.io-parser");Object.defineProperty(r,"protocol",{enumerable:!0,get:function(){return u.protocol}}),t.exports=d},{"./manager.js":299,"./socket.js":301,"./url.js":302,debug:104,"socket.io-parser":304}],299:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Manager=void 0;const o=e("engine.io-client"),c=e("./socket.js"),d=a(e("socket.io-parser")),u=e("./on.js"),l=e("./contrib/backo2.js"),h=e("@socket.io/component-emitter"),f=s(e("debug")).default("socket.io-client:manager");class p extends h.Emitter{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,o.installTimerFunctions(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(r=t.randomizationFactor)&&void 0!==r?r:.5),this.backoff=new l.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||d;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(f("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;f("opening %s",this.uri),this.engine=new o.Socket(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=u.on(t,"open",(function(){r.onopen(),e&&e()})),n=t=>{f("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},a=u.on(t,"error",n);if(!1!==this._timeout){const e=this._timeout;f("connect attempt will timeout after %d",e);const r=this.setTimeoutFn((()=>{f("connect attempt timed out after %d",e),i(),n(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}return this.subs.push(i),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){f("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(u.on(e,"ping",this.onping.bind(this)),u.on(e,"data",this.ondata.bind(this)),u.on(e,"error",this.onerror.bind(this)),u.on(e,"close",this.onclose.bind(this)),u.on(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){o.nextTick((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){f("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new c.Socket(this,e,t),this.nsps[e]=r),r}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return void f("socket %s is still active, skipping close",e)}this._close()}_packet(e){f("writing packet %j",e);const t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){f("cleanup"),this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){f("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){f("closed due to %s",e),this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)f("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();f("will wait %dms before reconnect attempt",t),this._reconnecting=!0;const r=this.setTimeoutFn((()=>{e.skipReconnect||(f("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(f("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):(f("reconnect success"),e.onreconnect())})))}),t);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}r.Manager=p},{"./contrib/backo2.js":297,"./on.js":300,"./socket.js":301,"@socket.io/component-emitter":40,debug:104,"engine.io-client":141,"socket.io-parser":304}],300:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.on=void 0,r.on=function(e,t,r){return e.on(t,r),function(){e.off(t,r)}}},{}],301:[function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Socket=void 0;const n=e("socket.io-parser"),a=e("./on.js"),s=e("@socket.io/component-emitter"),o=i(e("debug")).default("socket.io-client:socket"),c=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class d extends s.Emitter{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[a.on(e,"open",this.onopen.bind(this)),a.on(e,"packet",this.onpacket.bind(this)),a.on(e,"error",this.onerror.bind(this)),a.on(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(c.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const r={type:n.PacketType.EVENT,data:t,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++;o("emitting packet with ack id %d",e);const i=t.pop();this._registerAckCallback(e,i),r.id=e}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)?o("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r),this.flags={},this}_registerAckCallback(e,t){var r;const i=null!==(r=this.flags.timeout)&&void 0!==r?r:this._opts.ackTimeout;if(void 0===i)return void(this.acks[e]=t);const n=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&(o("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(t,1));o("event with ack id %d has timed out after %d ms",e,i),t.call(this,new Error("operation has timed out"))}),i),a=(...e)=>{this.io.clearTimeoutFn(n),t.apply(this,e)};a.withError=!0,this.acks[e]=a}emitWithAck(e,...t){return new Promise(((r,i)=>{const n=(e,t)=>e?i(e):r(t);n.withError=!0,t.push(n),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...i)=>{if(r!==this._queue[0])return;return null!==e?r.tryCount>this._opts.retries&&(o("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(e)):(o("packet [%d] was successfully sent",r.id),this._queue.shift(),t&&t(null,...i)),r.pending=!1,this._drainQueue()})),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(o("draining queue"),!this.connected||0===this._queue.length)return;const t=this._queue[0];!t.pending||e?(t.pending=!0,t.tryCount++,o("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)):o("packet [%d] has already been sent and is waiting for an ack",t.id)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){o("transport is open - connecting"),"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:n.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){o("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach((e=>{if(!this.sendBuffer.some((t=>String(t.id)===e))){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}}))}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case n.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case n.PacketType.EVENT:case n.PacketType.BINARY_EVENT:this.onevent(e);break;case n.PacketType.ACK:case n.PacketType.BINARY_ACK:this.onack(e);break;case n.PacketType.DISCONNECT:this.ondisconnect();break;case n.PacketType.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];o("emitting event %j",t),null!=e.id&&(o("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let r=!1;return function(...i){r||(r=!0,o("sending ack %j",i),t.packet({type:n.PacketType.ACK,id:e,data:i}))}}onack(e){const t=this.acks[e.id];"function"==typeof t?(delete this.acks[e.id],o("calling ack %s with %j",e.id,e.data),t.withError&&e.data.unshift(null),t.apply(this,e.data)):o("bad ack %s",e.id)}onconnect(e,t){o("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){o("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(o("performing disconnect (%s)",this.nsp),this.packet({type:n.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const r of t)r.apply(this,e.data)}}}r.Socket=d},{"./on.js":300,"@socket.io/component-emitter":40,debug:104,"socket.io-parser":304}],302:[function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.url=void 0;const n=e("engine.io-client"),a=i(e("debug")).default("socket.io-client:url");r.url=function(e,t="",r){let i=e;r=r||"undefined"!=typeof location&&location,null==e&&(e=r.protocol+"//"+r.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?r.protocol+e:r.host+e),/^(https?|wss?):\/\//.test(e)||(a("protocol-less url %s",e),e=void 0!==r?r.protocol+"//"+e:"https://"+e),a("parse %s",e),i=n.parse(e)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const s=-1!==i.host.indexOf(":")?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+s+":"+i.port+t,i.href=i.protocol+"://"+s+(r&&r.port===i.port?"":":"+i.port),i}},{debug:104,"engine.io-client":141}],303:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.reconstructPacket=r.deconstructPacket=void 0;const i=e("./is-binary.js");function n(e,t){if(!e)return e;if((0,i.isBinary)(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}if(Array.isArray(e)){const r=new Array(e.length);for(let i=0;i<e.length;i++)r[i]=n(e[i],t);return r}if("object"==typeof e&&!(e instanceof Date)){const r={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=n(e[i],t));return r}return e}function a(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=a(e[r],t);else if("object"==typeof e)for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=a(e[r],t));return e}r.deconstructPacket=function(e){const t=[],r=e.data,i=e;return i.data=n(r,t),i.attachments=t.length,{packet:i,buffers:t}},r.reconstructPacket=function(e,t){return e.data=a(e.data,t),delete e.attachments,e}},{"./is-binary.js":305}],304:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Decoder=r.Encoder=r.PacketType=r.protocol=void 0;const i=e("@socket.io/component-emitter"),n=e("./binary.js"),a=e("./is-binary.js"),s=(0,e("debug").default)("socket.io-parser"),o=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var c;r.protocol=5,function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(c=r.PacketType||(r.PacketType={}));function d(e){return"[object Object]"===Object.prototype.toString.call(e)}r.Encoder=class{constructor(e){this.replacer=e}encode(e){return s("encoding packet %j",e),e.type!==c.EVENT&&e.type!==c.ACK||!(0,a.hasBinary)(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==c.BINARY_EVENT&&e.type!==c.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),s("encoded %j as %s",e,t),t}encodeAsBinary(e){const t=(0,n.deconstructPacket)(e),r=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(r),i}};class u extends i.Emitter{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const r=t.type===c.BINARY_EVENT;r||t.type===c.BINARY_ACK?(t.type=r?c.EVENT:c.ACK,this.reconstructor=new l(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!(0,a.isBinary)(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const r={type:Number(e.charAt(0))};if(void 0===c[r.type])throw new Error("unknown packet type "+r.type);if(r.type===c.BINARY_EVENT||r.type===c.BINARY_ACK){const i=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const n=e.substring(i,t);if(n!=Number(n)||"-"!==e.charAt(t))throw new Error("Illegal attachments");r.attachments=Number(n)}if("/"===e.charAt(t+1)){const i=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}r.nsp=e.substring(i,t)}else r.nsp="/";const i=e.charAt(t+1);if(""!==i&&Number(i)==i){const i=t+1;for(;++t;){const r=e.charAt(t);if(null==r||Number(r)!=r){--t;break}if(t===e.length)break}r.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(!u.isPayloadValid(r.type,i))throw new Error("invalid payload");r.data=i}return s("decoded %s as %j",e,r),r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return d(t);case c.DISCONNECT:return void 0===t;case c.CONNECT_ERROR:return"string"==typeof t||d(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===o.indexOf(t[0]));case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}r.Decoder=u;class l{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=(0,n.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}},{"./binary.js":303,"./is-binary.js":305,"@socket.io/component-emitter":40,debug:104}],305:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.hasBinary=r.isBinary=void 0;const i="function"==typeof ArrayBuffer,n=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,a=Object.prototype.toString,s="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===a.call(Blob),o="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===a.call(File);function c(e){return i&&(e instanceof ArrayBuffer||n(e))||s&&e instanceof Blob||o&&e instanceof File}r.isBinary=c,r.hasBinary=function e(t,r){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let r=0,i=t.length;r<i;r++)if(e(t[r]))return!0;return!1}if(c(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&e(t[r]))return!0;return!1}},{}],306:[function(e,t,r){t.exports=n;var i=e("events").EventEmitter;function n(){i.call(this)}e("inherits")(n,i),n.Readable=e("readable-stream/readable.js"),n.Writable=e("readable-stream/writable.js"),n.Duplex=e("readable-stream/duplex.js"),n.Transform=e("readable-stream/transform.js"),n.PassThrough=e("readable-stream/passthrough.js"),n.Stream=n,n.prototype.pipe=function(e,t){var r=this;function n(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function a(){r.readable&&r.resume&&r.resume()}r.on("data",n),e.on("drain",a),e._isStdio||t&&!1===t.end||(r.on("end",o),r.on("close",c));var s=!1;function o(){s||(s=!0,e.end())}function c(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function d(e){if(u(),0===i.listenerCount(this,"error"))throw e}function u(){r.removeListener("data",n),e.removeListener("drain",a),r.removeListener("end",o),r.removeListener("close",c),r.removeListener("error",d),e.removeListener("error",d),r.removeListener("end",u),r.removeListener("close",u),e.removeListener("close",u)}return r.on("error",d),e.on("error",d),r.on("end",u),r.on("close",u),e.on("close",u),e.emit("pipe",r),e}},{events:91,inherits:174,"readable-stream/duplex.js":268,"readable-stream/passthrough.js":279,"readable-stream/readable.js":280,"readable-stream/transform.js":281,"readable-stream/writable.js":282}],307:[function(e,t,r){arguments[4][278][0].apply(r,arguments)},{dup:278,"safe-buffer":284}],308:[function(e,t,r){(function(t,i){(function(){var n=e("process/browser.js").nextTick,a=Function.prototype.apply,s=Array.prototype.slice,o={},c=0;function d(e,t){this._id=e,this._clearFn=t}r.setTimeout=function(){return new d(a.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new d(a.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(e){e.close()},d.prototype.unref=d.prototype.ref=function(){},d.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},r.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},r._unrefActive=r.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r.setImmediate="function"==typeof t?t:function(e){var t=c++,i=!(arguments.length<2)&&s.call(arguments,1);return o[t]=!0,n((function(){o[t]&&(i?e.apply(null,i):e.call(null),r.clearImmediate(t))})),t},r.clearImmediate="function"==typeof i?i:function(e){delete o[e]}}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":257,timers:308}],309:[function(e,t,r){!function(e,i){"use strict";var n="function",a="undefined",s="object",o="string",c="major",d="model",u="name",l="type",h="vendor",f="version",p="architecture",m="console",b="mobile",g="tablet",v="smarttv",y="wearable",_="embedded",w="Amazon",S="Apple",k="ASUS",R="BlackBerry",P="Browser",M="Chrome",E="Firefox",x="Google",T="Huawei",C="LG",I="Microsoft",D="Motorola",O="Opera",A="Samsung",L="Sharp",j="Sony",B="Xiaomi",N="Zebra",F="Facebook",U="Chromium OS",q="Mac OS",z=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},V=function(e,t){return typeof e===o&&-1!==G(t).indexOf(G(e))},G=function(e){return e.toLowerCase()},W=function(e,t){if(typeof e===o)return e=e.replace(/^\s\s*/,""),typeof t===a?e:e.substring(0,500)},H=function(e,t){for(var r,a,o,c,d,u,l=0;l<t.length&&!d;){var h=t[l],f=t[l+1];for(r=a=0;r<h.length&&!d&&h[r];)if(d=h[r++].exec(e))for(o=0;o<f.length;o++)u=d[++a],typeof(c=f[o])===s&&c.length>0?2===c.length?typeof c[1]==n?this[c[0]]=c[1].call(this,u):this[c[0]]=c[1]:3===c.length?typeof c[1]!==n||c[1].exec&&c[1].test?this[c[0]]=u?u.replace(c[1],c[2]):i:this[c[0]]=u?c[1].call(this,u,c[2]):i:4===c.length&&(this[c[0]]=u?c[3].call(this,u.replace(c[1],c[2])):i):this[c]=u||i;l+=2}},K=function(e,t){for(var r in t)if(typeof t[r]===s&&t[r].length>0){for(var n=0;n<t[r].length;n++)if(V(t[r][n],e))return"?"===r?i:r}else if(V(t[r],e))return"?"===r?i:r;return e},$={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},J={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[f,[u,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[f,[u,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[u,f],[/opios[\/ ]+([\w\.]+)/i],[f,[u,O+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[f,[u,O+" GX"]],[/\bopr\/([\w\.]+)/i],[f,[u,O]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[f,[u,"Baidu"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim)\s?(?:browser)?[\/ ]?([\w\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[u,f],[/\bddg\/([\w\.]+)/i],[f,[u,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[f,[u,"UC"+P]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[f,[u,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[u,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[f,[u,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[f,[u,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[f,[u,"Smart Lenovo "+P]],[/(avast|avg)\/([\w\.]+)/i],[[u,/(.+)/,"$1 Secure "+P],f],[/\bfocus\/([\w\.]+)/i],[f,[u,E+" Focus"]],[/\bopt\/([\w\.]+)/i],[f,[u,O+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[f,[u,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[u,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[u,O+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[f,[u,"MIUI "+P]],[/fxios\/([-\w\.]+)/i],[f,[u,E]],[/\bqihu|(qi?ho?o?|360)browser/i],[[u,"360 "+P]],[/(oculus|sailfish|huawei|vivo)browser\/([\w\.]+)/i],[[u,/(.+)/,"$1 "+P],f],[/samsungbrowser\/([\w\.]+)/i],[f,[u,A+" Internet"]],[/(comodo_dragon)\/([\w\.]+)/i],[[u,/_/g," "],f],[/metasr[\/ ]?([\d\.]+)/i],[f,[u,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[u,"Sogou Mobile"],f],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345Explorer)[\/ ]?([\w\.]+)/i],[u,f],[/(lbbrowser)/i,/\[(linkedin)app\]/i],[u],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[u,F],f],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[u,f],[/\bgsa\/([\w\.]+) .*safari\//i],[f,[u,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[f,[u,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[f,[u,M+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[u,M+" WebView"],f],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[f,[u,"Android "+P]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[u,f],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[f,[u,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[f,u],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[u,[f,K,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[u,f],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[u,"Netscape"],f],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[f,[u,E+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[u,f],[/(cobalt)\/([\w\.]+)/i],[u,[f,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[p,"amd64"]],[/(ia32(?=;))/i],[[p,G]],[/((?:i[346]|x)86)[;\)]/i],[[p,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[p,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[p,"armhf"]],[/windows (ce|mobile); ppc;/i],[[p,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[p,/ower/,"",G]],[/(sun4\w)[;\)]/i],[[p,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[p,G]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[h,A],[l,g]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[d,[h,A],[l,b]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[h,S],[l,b]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[h,S],[l,g]],[/(macintosh);/i],[d,[h,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[h,L],[l,b]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[h,T],[l,g]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[h,T],[l,b]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[d,/_/g," "],[h,B],[l,b]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/g," "],[h,B],[l,g]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[d,[h,"OPPO"],[l,b]],[/\b(opd2\d{3}a?) bui/i],[d,[h,"OPPO"],[l,g]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[h,"Vivo"],[l,b]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[h,"Realme"],[l,b]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[d,[h,D],[l,b]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[h,D],[l,g]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[h,C],[l,g]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[d,[h,C],[l,b]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[h,"Lenovo"],[l,g]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g," "],[h,"Nokia"],[l,b]],[/(pixel c)\b/i],[d,[h,x],[l,g]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[h,x],[l,b]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[d,[h,j],[l,b]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,"Xperia Tablet"],[h,j],[l,g]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[h,"OnePlus"],[l,b]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[h,w],[l,g]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,"Fire Phone $1"],[h,w],[l,b]],[/(playbook);[-\w\),; ]+(rim)/i],[d,h,[l,g]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[h,R],[l,b]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[h,k],[l,g]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[h,k],[l,b]],[/(nexus 9)/i],[d,[h,"HTC"],[l,g]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[d,/_/g," "],[l,b]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[h,"Acer"],[l,g]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[h,"Meizu"],[l,b]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[h,"Ulefone"],[l,b]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,d,[l,b]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,d,[l,g]],[/(surface duo)/i],[d,[h,I],[l,g]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[h,"Fairphone"],[l,b]],[/(u304aa)/i],[d,[h,"AT&T"],[l,b]],[/\bsie-(\w*)/i],[d,[h,"Siemens"],[l,b]],[/\b(rct\w+) b/i],[d,[h,"RCA"],[l,g]],[/\b(venue[\d ]{2,7}) b/i],[d,[h,"Dell"],[l,g]],[/\b(q(?:mv|ta)\w+) b/i],[d,[h,"Verizon"],[l,g]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[h,"Barnes & Noble"],[l,g]],[/\b(tm\d{3}\w+) b/i],[d,[h,"NuVision"],[l,g]],[/\b(k88) b/i],[d,[h,"ZTE"],[l,g]],[/\b(nx\d{3}j) b/i],[d,[h,"ZTE"],[l,b]],[/\b(gen\d{3}) b.+49h/i],[d,[h,"Swiss"],[l,b]],[/\b(zur\d{3}) b/i],[d,[h,"Swiss"],[l,g]],[/\b((zeki)?tb.*\b) b/i],[d,[h,"Zeki"],[l,g]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],d,[l,g]],[/\b(ns-?\w{0,9}) b/i],[d,[h,"Insignia"],[l,g]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[h,"NextBook"],[l,g]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],d,[l,b]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],d,[l,b]],[/\b(ph-1) /i],[d,[h,"Essential"],[l,b]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[h,"Envizen"],[l,g]],[/\b(trio[-\w\. ]+) b/i],[d,[h,"MachSpeed"],[l,g]],[/\btu_(1491) b/i],[d,[h,"Rotor"],[l,g]],[/(shield[\w ]+) b/i],[d,[h,"Nvidia"],[l,g]],[/(sprint) (\w+)/i],[h,d,[l,b]],[/(kin\.[onetw]{3})/i],[[d,/\./g," "],[h,I],[l,b]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[h,N],[l,g]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[h,N],[l,b]],[/smart-tv.+(samsung)/i],[h,[l,v]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,"SmartTV"],[h,A],[l,v]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,C],[l,v]],[/(apple) ?tv/i],[h,[d,S+" TV"],[l,v]],[/crkey/i],[[d,M+"cast"],[h,x],[l,v]],[/droid.+aft(\w+)( bui|\))/i],[d,[h,w],[l,v]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[h,L],[l,v]],[/(bravia[\w ]+)( bui|\))/i],[d,[h,j],[l,v]],[/(mitv-\w{5}) bui/i],[d,[h,B],[l,v]],[/Hbbtv.*(technisat) (.*);/i],[h,d,[l,v]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,W],[d,W],[l,v]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[l,v]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,d,[l,m]],[/droid.+; (shield) bui/i],[d,[h,"Nvidia"],[l,m]],[/(playstation [345portablevi]+)/i],[d,[h,j],[l,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[h,I],[l,m]],[/((pebble))app/i],[h,d,[l,y]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[h,S],[l,y]],[/droid.+; (glass) \d/i],[d,[h,x],[l,y]],[/droid.+; (wt63?0{2,3})\)/i],[d,[h,N],[l,y]],[/(quest( \d| pro)?)/i],[d,[h,F],[l,y]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[l,_]],[/(aeobc)\b/i],[d,[h,w],[l,_]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[l,b]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[l,g]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[l,g]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[l,b]],[/(android[-\w\. ]{0,9});.+buil/i],[d,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[f,[u,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[u,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[u,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,u]],os:[[/microsoft (windows) (vista|xp)/i],[u,f],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[u,[f,K,$]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[f,K,$],[u,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[u,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[u,q],[f,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[f,u],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[u,f],[/\(bb(10);/i],[f,[u,R]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[f,[u,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[f,[u,E+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[u,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[f,[u,"watchOS"]],[/crkey\/([\d\.]+)/i],[f,[u,M+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[u,U],f],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[u,f],[/(sunos) ?([\w\.\d]*)/i],[[u,"Solaris"],f],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[u,f]]},Y=function(t,r){if(typeof t===s&&(r=t,t=i),!(this instanceof Y))return new Y(t,r).getResult();var m=typeof e!==a&&e.navigator?e.navigator:i,v=t||(m&&m.userAgent?m.userAgent:""),y=m&&m.userAgentData?m.userAgentData:i,_=r?function(e,t){var r={};for(var i in e)t[i]&&t[i].length%2==0?r[i]=t[i].concat(e[i]):r[i]=e[i];return r}(J,r):J,w=m&&m.userAgent==v;return this.getBrowser=function(){var e,t={};return t[u]=i,t[f]=i,H.call(t,v,_.browser),t[c]=typeof(e=t[f])===o?e.replace(/[^\d\.]/g,"").split(".")[0]:i,w&&m&&m.brave&&typeof m.brave.isBrave==n&&(t[u]="Brave"),t},this.getCPU=function(){var e={};return e[p]=i,H.call(e,v,_.cpu),e},this.getDevice=function(){var e={};return e[h]=i,e[d]=i,e[l]=i,H.call(e,v,_.device),w&&!e[l]&&y&&y.mobile&&(e[l]=b),w&&"Macintosh"==e[d]&&m&&typeof m.standalone!==a&&m.maxTouchPoints&&m.maxTouchPoints>2&&(e[d]="iPad",e[l]=g),e},this.getEngine=function(){var e={};return e[u]=i,e[f]=i,H.call(e,v,_.engine),e},this.getOS=function(){var e={};return e[u]=i,e[f]=i,H.call(e,v,_.os),w&&!e[u]&&y&&y.platform&&"Unknown"!=y.platform&&(e[u]=y.platform.replace(/chrome os/i,U).replace(/macos/i,q)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return v},this.setUA=function(e){return v=typeof e===o&&e.length>500?W(e,500):e,this},this.setUA(v),this};Y.VERSION="1.0.38",Y.BROWSER=z([u,f,c]),Y.CPU=z([p]),Y.DEVICE=z([d,h,l,m,b,v,g,y,_]),Y.ENGINE=Y.OS=z([u,f]),typeof r!==a?(typeof t!==a&&t.exports&&(r=t.exports=Y),r.UAParser=Y):typeof define===n&&define.amd?define((function(){return Y})):typeof e!==a&&(e.UAParser=Y);var X=typeof e!==a&&(e.jQuery||e.Zepto);if(X&&!X.ua){var Z=new Y;X.ua=Z.getResult(),X.ua.get=function(){return Z.getUA()},X.ua.set=function(e){Z.setUA(e);var t=Z.getResult();for(var r in t)X.ua[r]=t[r]}}}("object"==typeof window?window:this)},{}],310:[function(e,t,r){"use strict";const i=e("unique-random");t.exports=e=>{const t=i(0,e.length-1);return()=>e[t()]}},{"unique-random":311}],311:[function(e,t,r){"use strict";t.exports=(e,t)=>{let r;return function i(){const n=Math.floor(Math.random()*(t-e+1)+e);return r=n===r&&e!==t?i():n,r}}},{}],312:[function(e,t,r){(function(e){(function(){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var i=!1;return function(){if(!i){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],313:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],314:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],315:[function(e,t,r){(function(t,i){(function(){var n=/%[sdj%]/g;r.format=function(e){if(!g(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(o(arguments[r]));return t.join(" ")}r=1;for(var i=arguments,a=i.length,s=String(e).replace(n,(function(e){if("%%"===e)return"%";if(r>=a)return e;switch(e){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":try{return JSON.stringify(i[r++])}catch(e){return"[Circular]"}default:return e}})),c=i[r];r<a;c=i[++r])m(c)||!_(c)?s+=" "+c:s+=" "+o(c);return s},r.deprecate=function(e,n){if(v(i.process))return function(){return r.deprecate(e,n).apply(this,arguments)};if(!0===t.noDeprecation)return e;var a=!1;return function(){if(!a){if(t.throwDeprecation)throw new Error(n);t.traceDeprecation?console.trace(n):console.error(n),a=!0}return e.apply(this,arguments)}};var a,s={};function o(e,t){var i={seen:[],stylize:d};return arguments.length>=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),p(t)?i.showHidden=t:t&&r._extend(i,t),v(i.showHidden)&&(i.showHidden=!1),v(i.depth)&&(i.depth=2),v(i.colors)&&(i.colors=!1),v(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=c),u(i,e,i.depth)}function c(e,t){var r=o.styles[t];return r?"["+o.colors[r][0]+"m"+e+"["+o.colors[r][1]+"m":e}function d(e,t){return e}function u(e,t,i){if(e.customInspect&&t&&k(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(i,e);return g(n)||(n=u(e,n,i)),n}var a=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(g(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(b(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(m(t))return e.stylize("null","null")}(e,t);if(a)return a;var s=Object.keys(t),o=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),S(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return l(t);if(0===s.length){if(k(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(y(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(w(t))return e.stylize(Date.prototype.toString.call(t),"date");if(S(t))return l(t)}var d,_="",R=!1,P=["{","}"];(f(t)&&(R=!0,P=["[","]"]),k(t))&&(_=" [Function"+(t.name?": "+t.name:"")+"]");return y(t)&&(_=" "+RegExp.prototype.toString.call(t)),w(t)&&(_=" "+Date.prototype.toUTCString.call(t)),S(t)&&(_=" "+l(t)),0!==s.length||R&&0!=t.length?i<0?y(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),d=R?function(e,t,r,i,n){for(var a=[],s=0,o=t.length;s<o;++s)E(t,String(s))?a.push(h(e,t,r,i,String(s),!0)):a.push("");return n.forEach((function(n){n.match(/^\d+$/)||a.push(h(e,t,r,i,n,!0))})),a}(e,t,i,o,s):s.map((function(r){return h(e,t,i,o,r,R)})),e.seen.pop(),function(e,t,r){var i=e.reduce((function(e,t){return t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);if(i>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(d,_,P)):P[0]+_+P[1]}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,r,i,n,a){var s,o,c;if((c=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?o=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(o=e.stylize("[Setter]","special")),E(i,n)||(s="["+n+"]"),o||(e.seen.indexOf(c.value)<0?(o=m(r)?u(e,c.value,null):u(e,c.value,r-1)).indexOf("\n")>-1&&(o=a?o.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+o.split("\n").map((function(e){return" "+e})).join("\n")):o=e.stylize("[Circular]","special")),v(s)){if(a&&n.match(/^\d+$/))return o;(s=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+o}function f(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function m(e){return null===e}function b(e){return"number"==typeof e}function g(e){return"string"==typeof e}function v(e){return void 0===e}function y(e){return _(e)&&"[object RegExp]"===R(e)}function _(e){return"object"==typeof e&&null!==e}function w(e){return _(e)&&"[object Date]"===R(e)}function S(e){return _(e)&&("[object Error]"===R(e)||e instanceof Error)}function k(e){return"function"==typeof e}function R(e){return Object.prototype.toString.call(e)}function P(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(v(a)&&(a=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(a)){var i=t.pid;s[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,i,t)}}else s[e]=function(){};return s[e]},r.inspect=o,o.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},o.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=f,r.isBoolean=p,r.isNull=m,r.isNullOrUndefined=function(e){return null==e},r.isNumber=b,r.isString=g,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=v,r.isRegExp=y,r.isObject=_,r.isDate=w,r.isError=S,r.isFunction=k,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var M=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function E(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[P(e.getHours()),P(e.getMinutes()),P(e.getSeconds())].join(":"),[e.getDate(),M[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!_(t))return e;for(var r=Object.keys(t),i=r.length;i--;)e[r[i]]=t[r[i]];return e}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":314,_process:257,inherits:313}],316:[function(require,module,exports){var indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0;r<e.length;r++)if(e[r]===t)return r;return-1},Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r<e.length;r++)t(e[r],r,e)},defineProp=function(){try{return Object.defineProperty({},"_",{}),function(e,t,r){Object.defineProperty(e,t,{writable:!0,enumerable:!1,configurable:!0,value:r})}}catch(e){return function(e,t,r){e[t]=r}}}(),globals=["Array","Boolean","Date","Error","EvalError","Function","Infinity","JSON","Math","NaN","Number","Object","RangeError","ReferenceError","RegExp","String","SyntaxError","TypeError","URIError","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","eval","isFinite","isNaN","parseFloat","parseInt","undefined","unescape"];function Context(){}Context.prototype={};var Script=exports.Script=function(e){if(!(this instanceof Script))return new Script(e);this.code=e};Script.prototype.runInContext=function(e){if(!(e instanceof Context))throw new TypeError("needs a 'context' argument.");var t=document.createElement("iframe");t.style||(t.style={}),t.style.display="none",document.body.appendChild(t);var r=t.contentWindow,i=r.eval,n=r.execScript;!i&&n&&(n.call(r,"null"),i=r.eval),forEach(Object_keys(e),(function(t){r[t]=e[t]})),forEach(globals,(function(t){e[t]&&(r[t]=e[t])}));var a=Object_keys(r),s=i.call(r,this.code);return forEach(Object_keys(r),(function(t){(t in e||-1===indexOf(a,t))&&(e[t]=r[t])})),forEach(globals,(function(t){t in e||defineProp(e,t,r[t])})),document.body.removeChild(t),s},Script.prototype.runInThisContext=function(){return eval(this.code)},Script.prototype.runInNewContext=function(e){var t=Script.createContext(e),r=this.runInContext(t);return e&&forEach(Object_keys(t),(function(r){e[r]=t[r]})),r},forEach(Object_keys(Script.prototype),(function(e){exports[e]=Script[e]=function(t){var r=Script(t);return r[e].apply(r,[].slice.call(arguments,1))}})),exports.isContext=function(e){return e instanceof Context},exports.createScript=function(e){return exports.Script(e)},exports.createContext=Script.createContext=function(e){var t=new Context;return"object"==typeof e&&forEach(Object_keys(e),(function(r){t[r]=e[r]})),t}},{}],317:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.Logger=void 0;var n=i(e("@babel/runtime/helpers/classCallCheck")),a=i(e("@babel/runtime/helpers/createClass")),s=e("debug"),o="cp2p-client";r.Logger=function(){return(0,a.default)((function e(t){(0,n.default)(this,e),t?(this._debug=s("".concat(o,":").concat(t)),this._info=s("".concat(o,":INFO:").concat(t)),this._warn=s("".concat(o,":WARN:").concat(t)),this._error=s("".concat(o,":ERROR:").concat(t))):(this._debug=s(o),this._info=s("".concat(o,":INFO")),this._warn=s("".concat(o,":WARN")),this._error=s("".concat(o,":ERROR"))),this._debug.log=console.info.bind(console),this._info.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}),[{key:"debug",get:function(){return this._debug}},{key:"info",get:function(){return this._info}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}])}()},{"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/interopRequireDefault":30,debug:104}],318:[function(e,t,r){(function(t){(function(){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.P2pSdk=void 0;var n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator")),s=i(e("@babel/runtime/helpers/classCallCheck")),o=i(e("@babel/runtime/helpers/createClass")),c=i(e("@babel/runtime/helpers/possibleConstructorReturn")),d=i(e("@babel/runtime/helpers/getPrototypeOf")),u=i(e("@babel/runtime/helpers/inherits")),l=i(e("@babel/runtime/helpers/defineProperty")),h=(e("../utils/getRandomInt.js"),e("../utils/uuidv4.js")),f=e("../utils/getAudioVideoInputs.js"),p=e("../utils/getDeviceId.js"),m=(e("../utils/sleep.js"),e("./Logger.js")),b=e("../utils/gumConstraints.js"),g=e("./SocketTransport.js"),v=e("events");function y(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 _(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?y(Object(r),!0).forEach((function(t){(0,l.default)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function w(e,t,r){return t=(0,d.default)(t),(0,c.default)(e,S()?Reflect.construct(t,r||[],(0,d.default)(e).constructor):t.apply(e,r))}function S(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(S=function(){return!!e})()}e("./platform.js");var k=new m.Logger("Room");r.P2pSdk=function(e){function r(e){var t,i=e.peerId,n=e.roomId,a=e.peerName,o=e.role,c=e.url;return(0,s.default)(this,r),t=w(this,r),(0,l.default)(t,"handleNegotiationNeededEvent",(function(){k.debug("handleNegotiationNeededEvent() | needed to negotiate a new negotiation");t.restartICE()})),(0,l.default)(t,"handleRemoveTrackEvent",(function(){k.debug("handleRemoveTrackEvent() | Track removed by remote peer. Need to handle UI locally."),t.emit("videoToggle",{status:!1,peer:"other"})})),t._closed=!1,t._roomId=n,t._socket=null,t._peerConnection=null,t._myDisplayName=a,t._myPeerId=i,t._myRole=o,t._localStream=null,t._remoteDisplayName=null,t._remotePeerId=null,t._remoteRole=null,t._remoteStream=null,t._canvas=null,t._imageData=null,t._imageWidth=1280,t._imageHeight=720,t._availableMediaInputs=null,t._userAgent={name:platform.name,version:platform.version,os:platform.os.family,description:platform.description},t._remoteMediaInputs=null,t._remoteUserAgent=null,t._statsCaptureInterval=null,t._localStats=null,t._remoteStats=null,t._otherPeerConnected=null,t._data={},t._url=c,t.prepareForCall(),k.debug("user agent is:%o",t._userAgent),t}return(0,u.default)(r,e),(0,o.default)(r,[{key:"imageData",get:function(){return this._imageData}},{key:"roomId",get:function(){return this._roomId}},{key:"localStream",get:function(){return this._localStream}},{key:"remoteStream",get:function(){return this._remoteStream}},{key:"myName",get:function(){return this._myDisplayName},set:function(e){this._myDisplayName=e}},{key:"myId",get:function(){return this._myPeerId}},{key:"myRole",get:function(){return this._myRole}},{key:"remoteName",get:function(){return this._remoteDisplayName}},{key:"remoteId",get:function(){return this._remotePeerId}},{key:"remoteRole",get:function(){return this._remoteRole}},{key:"imageHeight",get:function(){return this._imageHeight}},{key:"imageWidth",get:function(){return this._imageWidth}},{key:"userAgent",get:function(){return this._userAgent}},{key:"mediaInputs",get:function(){return this._availableMediaInputs}},{key:"remoteUserAgent",get:function(){return this._remoteUserAgent}},{key:"remoteMediaInputs",get:function(){return this._remoteMediaInputs}},{key:"localStats",get:function(){return this._localStats}},{key:"remoteStats",get:function(){return this._remoteStats}},{key:"pc",get:function(){return this._peerConnection}},{key:"data",get:function(){return this._data},set:function(e){throw new Error("Can't set the whole of data object.")}},{key:"setImageProps",value:function(e){var t=e.width,r=e.height;t&&r?(this._imageHeight=r,this._imageWidth=t):this.clientErrorHandler({reason:"Both width and height are required to set the new image properties. ",error:null})}},{key:"prepareForCall",value:(j=(0,a.default)(n.default.mark((function e(){var t,r=this;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this,(0,f.chooseMediaLabel)().then(function(){var e=(0,a.default)(n.default.mark((function e(i){var a,s,o;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!i.error){e.next=15;break}e.t0=i.error,e.next="NotAllowedError"===e.t0?4:"NotFoundError"===e.t0?7:"NotReadableError"===e.t0?10:13;break;case 4:return a="".concat(i.error," : ").concat(i.reason,'!! You have denied the access to your Mic!! If you wish to join the room with video, please allow the camera access by clicking on the camera icon in the address bar Or by going to " chrome://settings/content#media-stream-mic " link in your chrome.'),r.clientErrorHandler({reason:a,error:null}),e.abrupt("break",13);case 7:return s="".concat(i.error," : ").concat(i.reason,"!! No Microphone could be found!! If you have a camera or microphone in your computer but it is not able to detect them, please refresh your browser again or restart the browser after closing all the opened tabs."),r.clientErrorHandler({reason:s,error:null}),e.abrupt("break",13);case 10:return o="".concat(i.error," : ").concat(i.reason,"!! A hardware error occured at the OS OR browser Or Webpage level. If you have a microphone in your computer but it is not able to detect them, please refresh your browser again or restart the browser after closing all the opened tabs."),r.clientErrorHandler({reason:o,error:null}),e.abrupt("break",13);case 13:e.next=21;break;case 15:if(!(i.audioLabels&&i.audioLabels.length>0&&i.videoLabels&&i.videoLabels.length>0)){e.next=21;break}return t._availableMediaInputs={audioInputs:i.audioLabels,videoInputs:i.videoLabels},k.debug("available A/V inputs:%o",t.mediaInputs),e.next=20,t.getUserMedia();case 20:t.emit("mediaInputs");case 21:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),navigator.mediaDevices.ondevicechange=function(){var e=(0,a.default)(n.default.mark((function e(r){var i;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return k.info("Media devices changed!"),e.next=3,(0,f.updatedDeviceList)();case 3:(i=e.sent).audioLabels&&i.audioLabels.length>0&&i.videoLabels&&i.videoLabels.length>0&&(t._availableMediaInputs={audioInputs:i.audioLabels,videoInputs:i.videoLabels},k.debug("updated A/V inputs:%o",t.mediaInputs),t.emit("mediaInputs"),"client"===t.myRole&&t.pc&&(k.info("Going to update the agent about the updated media devices list."),t.send({type:"mediaListUpdated",mediaInputs:t.mediaInputs})));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();case 3:case"end":return e.stop()}}),e,this)}))),function(){return j.apply(this,arguments)})},{key:"send",value:function(e){this._closed||this._socket.send(e)}},{key:"inform",value:function(e){if(!this._closed){var t={type:"information",msg:e};this._socket.send(t)}}},{key:"request",value:(L=(0,a.default)(n.default.mark((function e(t){var r,i,a;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.type,i=t.message,e.next=3,this._socket.request({type:r,message:i});case 3:if(!(a=e.sent)){e.next=6;break}return e.abrupt("return",a);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"gotMessageFromServer",value:function(e){switch(k.debug("Got message:%o",e),e.type){case"login":this.handleLogin(e.details);break;case"offer":k.debug("inside offer"),this.handleOffer({offer:e.offer,peer:e.peer,name:e.name});break;case"answer":k.debug("inside answer"),this.handleAnswer(e);break;case"candidate":k.debug("inside handle candidate"),this.handleCandidate(e.candidate);break;case"leave":this.handleLeave(),this.emit("peerHangUp");break;case"audioToggle":this.emit("audioToggle",{status:e.status,peer:"other"});break;case"videoToggle":this.emit("videoToggle",{status:e.status,peer:"other"});break;case"remoteStreamToggle":this.handleRemoteStreamToggle(e);break;case"chatMessage":this.emit("chatMessage",e.message);break;case"imageCapture":this.captureImage("local");break;case"mediaChange":this.changeRemoteMediaSource(e);break;case"requestStats":this.sendRequestedstats();break;case"statsFetched":this._remoteStats=e.stats,this.emit("remoteStats");break;case"information":this.emit("information",e.msg);break;case"iceRestart":this.handleIceRestart(e);break;case"iceRestarted":this.handleIceRestartResponse(e);break;case"nameUpdate":this._remoteDisplayName=e.name,this.emit("peerName");break;case"mediaListUpdated":this._remoteMediaInputs=e.mediaInputs,this.emit("remoteMediaInputs");break;case"peerLeft":this.pc||(this._remoteDisplayName=null,this._remotePeerId=null,this._remoteRole=null,this._otherPeerConnected=!1,this.emit("peerJoin","None"),alert("Other person disconnected from the room"));break;case"error":this.emit("serverError",e.details)}}},{key:"getUserMedia",value:(A=(0,a.default)(n.default.mark((function e(){var t=this;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:k.debug("Inside getusermedia"),this._localStream?k.debug("Local stream already acquired! Waiting for call!"):navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia(b.avConstraints).then((function(e){return t.getUserMediaSuccess(e)})).catch((function(e){return t.clientErrorHandler({reason:"Error while acquiring camera/mic",error:e})})):alert("Your browser does not support getUserMedia API");case 2:case"end":return e.stop()}}),e,this)}))),function(){return A.apply(this,arguments)})},{key:"getUserMediaSuccess",value:function(e){var t=this,r=this;k.debug("Inside getUserMediaSuccess"),this._localStream=e,this.emit("localStream"),this._socket=new g.SocketTransport({url:this._url,roomId:this._roomId,peerId:this._myPeerId,peerName:this._myDisplayName,role:this._myRole}),this._socket.on("message",(function(e){return t.gotMessageFromServer(e)})),this._socket.on("connected",(0,a.default)(n.default.mark((function e(){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!r.pc){e.next=6;break}if(k.debug("Socket reconnection happened after a disconnection, ICEState:%s",r._peerConnection.iceConnectionState),"failed"!==r._peerConnection.iceConnectionState&&"disconnected"!==r._peerConnection.iceConnectionState){e.next=6;break}return k.debug("Going to restart ICE as ICE is not in connected state!!"),e.next=6,r.restartICE();case 6:case"end":return e.stop()}}),e)}))))}},{key:"handleAudioToggle",value:function(){var e=this._localStream.getAudioTracks()[0];e.enabled=!e.enabled,this.send({type:"audioToggle",status:e.enabled}),this.emit("audioToggle",{status:e.enabled,peer:"self"})}},{key:"handleVideoToggle",value:function(){var e=this._localStream.getVideoTracks()[0];e.enabled=!e.enabled,this.send({type:"videoToggle",status:e.enabled}),this.emit("videoToggle",{status:e.enabled,peer:"self"})}},{key:"handleVideoToggleNew",value:function(){var e=this,t=this;if(this._peerConnection){var r=this._peerConnection.getSenders().find((function(e){return e.track&&"video"==e.track.kind}));if(r){k.debug("found sender:%o",r),this._peerConnection.removeTrack(r);var i=this._localStream.getVideoTracks()[0];i&&(i.stop(),this._localStream.removeTrack(i)),this.send({type:"videoToggle",status:!1}),this.emit("videoToggle",{status:!1,peer:"self"})}else k.debug("sender not found. Going to create a new video track."),navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia(_(_({},b.avConstraints),{},{audio:!1})).then((function(e){var r=e.getVideoTracks()[0];t._localStream.addTrack(r),t._peerConnection.addTrack(r),t.send({type:"videoToggle",status:!0}),t.emit("localStream"),t.emit("videoToggle",{status:!0,peer:"self"})})).catch((function(t){return e.clientErrorHandler({reason:"Error while acquiring camera/mic",error:t})})):alert("Your browser does not support getUserMedia API")}else k.warn("Peer connection not found!")}},{key:"handleRemoteAudioToggle",value:function(){this.send({type:"remoteStreamToggle",streamType:"audio"})}},{key:"handleRemoteVideoToggle",value:function(){this.send({type:"remoteStreamToggle",streamType:"video"})}},{key:"handleRemoteStreamToggle",value:function(e){k.debug("inside remote stream toggle"),"audio"===e.streamType?this.handleAudioToggle():"video"===e.streamType?this.handleVideoToggle():k.warn("Invalid stream type!")}},{key:"sendChatMessage",value:function(e){e&&" "!==e?this.send({type:"chatMessage",message:e}):this.clientErrorHandler({reason:"Chat message need to have a valid value!",error:null})}},{key:"informPeer",value:(O=(0,a.default)(n.default.mark((function e(){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.remoteId&&this.send({type:"nameUpdate",name:this.myName});case 1:case"end":return e.stop()}}),e,this)}))),function(){return O.apply(this,arguments)})},{key:"handleLogin",value:function(e){e&&(k.debug("All available users:%o",e),this._remoteDisplayName=e.displayName,this._remotePeerId=e.peerId,this._remoteRole=e.role),this._otherPeerConnected=!0,this.emit("peerJoin",this._remoteDisplayName)}},{key:"gotRemoteTrack",value:(D=(0,a.default)(n.default.mark((function e(t){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:k.debug("inside got remote track:%o",t),t.streams&&t.streams[0]?(k.debug("Got a remote stream"),this._remoteStream=t.streams[0]):(this._remoteStream=new MediaStream,this._remoteStream.addTrack(t.track),k.debug("Got a remote track")),this.emit("remoteStream");case 3:case"end":return e.stop()}}),e,this)}))),function(e){return D.apply(this,arguments)})},{key:"_onICeCandidate",value:function(e){k.debug("onicecandidate",e.candidate),e.candidate&&this.send({type:"candidate",candidate:e.candidate,peer:this._remotePeerId})}},{key:"createPeerOffer",value:(I=(0,a.default)(n.default.mark((function e(t){var r,i,s,o=this;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this,e.next=3,this._socket.request({type:"fetchIceServers",message:{}});case 3:return i=e.sent,this._peerConnection=new RTCPeerConnection({iceServers:i}),k.debug("connection state in createPeeroffer():%s",this._peerConnection.connectionState),this._peerConnection.onicecandidate=function(e){o._onICeCandidate(e)},this._localStream.getTracks().forEach((function(e){return o._peerConnection.addTrack(e,o._localStream)})),e.next=12,this._peerConnection.createOffer().catch((function(e){alert("Error when creating an offer",e),k.error("Error when creating an offer:%o",e)}));case 12:return s=e.sent,e.next=15,this._peerConnection.setLocalDescription(s);case 15:this.send({type:"offer",offer:r._peerConnection.localDescription,peer:r._remotePeerId,name:r.myName}),this._peerConnection.ontrack=function(e){return r.gotRemoteTrack(e)},this._peerConnection.addEventListener("iceconnectionstatechange",function(){var e=(0,a.default)(n.default.mark((function e(t){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:k.debug("Current ICEState:%s",r._peerConnection.iceConnectionState),"failed"!==r._peerConnection.iceConnectionState&&"disconnected"!==r._peerConnection.iceConnectionState||(k.debug("Ice connection failed!! with socket connection status:%s",r._socket.connectionStatus),r.emit("iceFailure"));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),this._peerConnection.onnegotiationneeded=function(){return o.handleNegotiationNeededEvent()},this._peerConnection.onremovetrack=function(){return o.handleRemoveTrackEvent()};case 20:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"handleOffer",value:(C=(0,a.default)(n.default.mark((function e(t){var r,i,s,o,c,d=this;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.peer,i=t.name,s=t.offer,o=this,e.next=4,this._socket.request({type:"fetchIceServers",message:{}});case 4:c=e.sent,this._peerConnection=new RTCPeerConnection({iceServers:c}),k.debug("Peer connection in handle offer is:%s",this._peerConnection),this._remoteDisplayName=i,this._remotePeerId=r,this._peerConnection.setRemoteDescription(new RTCSessionDescription(s)),this._localStream.getTracks().forEach((function(e){return d._peerConnection.addTrack(e,d._localStream)})),this._peerConnection.createAnswer().then((function(e){return o._peerConnection.setLocalDescription(e)})).then((function(){k.debug("Ice already completed. sending answer!!"),o.send({type:"answer",answer:o._peerConnection.localDescription,peer:o._remotePeerId,mediaInputs:o.mediaInputs,userAgent:o.userAgent})})).catch((function(e){alert("Error when creating an answer"),k.error("Error while creating answer:%o",e)})),this._peerConnection.ontrack=function(e){return o.gotRemoteTrack(e)},this._peerConnection.onicecandidate=function(e){d._onICeCandidate(e)},this._peerConnection.addEventListener("iceconnectionstatechange",function(){var e=(0,a.default)(n.default.mark((function e(t){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:k.debug("Current ICEState:%s",o._peerConnection.iceConnectionState),"failed"!==o._peerConnection.iceConnectionState&&"disconnected"!==o._peerConnection.iceConnectionState||(k.debug("Ice connection failed!! with socket connection status:%s",o._socket.connectionStatus),o.emit("iceFailure"));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),this._peerConnection.onnegotiationneeded=function(){return d.handleNegotiationNeededEvent()},this._peerConnection.onremovetrack=function(){return d.handleRemoveTrackEvent()},this.emit("offerReceived");case 18:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"handleAnswer",value:function(e){k.debug("answer:%o ",e),this._peerConnection.setRemoteDescription(new RTCSessionDescription(e.answer)),this._remoteMediaInputs=e.mediaInputs,this._remoteUserAgent=e.userAgent,this.emit("remoteMediaInputs")}},{key:"handleCandidate",value:(T=(0,a.default)(n.default.mark((function e(t){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pc?(k.debug("Peerconnection available, Inside handle candidate for remote icecandidates"),this._peerConnection.addIceCandidate(new RTCIceCandidate(t)).catch((function(e){k.error("Error while adding iceCandidate",e)}))):k.warn("Candidate arrived before peer connection instantiation:%o",t);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"restartICE",value:(x=(0,a.default)(n.default.mark((function e(){var t;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer({iceRestart:!0});case 2:return t=e.sent,e.next=5,this._peerConnection.setLocalDescription(t);case 5:this.send({type:"iceRestart",offer:t});case 6:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"handleIceRestart",value:(E=(0,a.default)(n.default.mark((function e(t){var r;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return k.debug("Ice restart message received!!"),this._peerConnection.setRemoteDescription(t.offer),e.next=4,this._peerConnection.createAnswer();case 4:return r=e.sent,e.next=7,this._peerConnection.setLocalDescription(r);case 7:this.send({type:"iceRestarted",answer:r});case 8:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"handleIceRestartResponse",value:(M=(0,a.default)(n.default.mark((function e(t){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:k.debug("Ice restart message response received!!"),this._peerConnection.setRemoteDescription(t.answer);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return M.apply(this,arguments)})},{key:"informRoomLeave",value:(P=(0,a.default)(n.default.mark((function e(){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.send({type:"leave",peer:this.remoteId}),e.next=3,this.handleLeave();case 3:case"end":return e.stop()}}),e,this)}))),function(){return P.apply(this,arguments)})},{key:"handleLeave",value:(R=(0,a.default)(n.default.mark((function e(){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._peerConnection?(this._peerConnection.ontrack=null,this._peerConnection.onremovetrack=null,this._peerConnection.onremovestream=null,this._peerConnection.onicecandidate=null,this._peerConnection.oniceconnectionstatechange=null,this._peerConnection.onsignalingstatechange=null,this._peerConnection.onicegatheringstatechange=null,this._peerConnection.onnegotiationneeded=null,this._localStream&&this._localStream.getTracks().forEach((function(e){return e.stop()})),this._remoteStream&&this._remoteStream.getTracks().forEach((function(e){return e.stop()})),this._peerConnection.close(),this._peerConnection=null,this._remoteDisplayName=null,this._remotePeerId=null,this._remoteStream=null,this._localStream=null,this._canvas=null,this._imageData=null,this._imageWidth=640,this._imageHeight=480,this._socket.close()):k.error("No peerconnection object found!");case 1:case"end":return e.stop()}}),e,this)}))),function(){return R.apply(this,arguments)})},{key:"changeRemoteMediaSource",value:(S=(0,a.default)(n.default.mark((function e(t){var r,i;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.label,i=t.mediaType,!r||"video"!==i&&"audio"!==i){e.next=5;break}this.handleReplaceTrack({label:r,mediaType:i}),e.next=7;break;case 5:return this.send({type:"error",details:{reason:"Can't change remote media source as either media label or media type is not available!"}}),e.abrupt("return");case 7:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"handleReplaceTrack",value:(y=(0,a.default)(n.default.mark((function e(t){var r,i,a,s,o,c,d,u,l;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.label,i=t.mediaType,e.prev=1,e.next=4,(0,p.getDeviceId)(r);case 4:return c=e.sent,"video"===i?(b.videoConstraints.video.deviceId.exact=c,o=b.videoConstraints,a=this._localStream.getVideoTracks()[0]):"audio"===i?(b.audioConstraints.audio.deviceId.exact=c,o=b.audioConstraints,a=this._localStream.getAudioTracks()[0]):k.error("Unknown media type:%s",i),d=a.enabled,a.stop(),k.debug("selected constraints are:%o",o),e.next=11,navigator.mediaDevices.getUserMedia(o);case 11:u=e.sent,k.debug("new stream is:%o",u),"video"===i?s=u.getVideoTracks()[0]:"audio"===i&&(s=u.getAudioTracks()[0]),s.enabled=d,this._peerConnection&&(l=this._peerConnection.getSenders().find((function(e){return e.track.kind==s.kind})),k.debug("found sender:%o",l),l.replaceTrack(s)),this._localStream.removeTrack(a),this._localStream.addTrack(s),e.next=24;break;case 20:e.prev=20,e.t0=e.catch(1),k.error("Error while replace media track:%o",e.t0),this.clientErrorHandler({reason:"Error while replacing media track with new source",error:e.t0});case 24:case"end":return e.stop()}}),e,this,[[1,20]])}))),function(e){return y.apply(this,arguments)})},{key:"captureImage",value:(v=(0,a.default)(n.default.mark((function e(t){var r,i,a,s,o;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=document.createElement("canvas"),i=r.getContext("2d"),a=this._imageWidth,s=this._imageHeight,k.debug("height:%s and width:%s",a,s),r.width=a,r.height=s,"local"===t?i.drawImage(localVideo,0,0,a,s):i.drawImage(remoteVideo,0,0,a,s),o=r.toDataURL("image/png"),this._canvas=r,this._imageData=o,this.emit("imageCaptured");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"clearImage",value:(m=(0,a.default)(n.default.mark((function e(){var t,r,i;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this._canvas,(r=t.getContext("2d")).fillStyle="#AAA",r.fillRect(0,0,t.width,t.height),i=t.toDataURL("image/png"),this._imageData=i;case 6:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"captureRemoteImage",value:function(){this.send({type:"imageCapture"})}},{key:"remoteCamChange",value:function(e){e?this.send({type:"mediaChange",mediaType:"video",label:e}):this.clientErrorHandler({reason:"A valid camera name must be selected for to change the remote camera!",error:null})}},{key:"remoteMicChange",value:function(e){e?this.send({type:"mediaChange",mediaType:"audio",label:e}):this.clientErrorHandler({reason:"A valid mic name must be selected for to change the remote mic!",error:null})}},{key:"requestStats",value:function(){this.send({type:"requestStats"})}},{key:"captureStats",value:(d=(0,a.default)(n.default.mark((function e(){var t,r=this;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this,e.abrupt("return",new Promise((function(e){r._peerConnection.getStats(null).then((function(r){var i={};r.forEach((function(e){["inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","local-candidate","remote-candidate","candidate-pair"].includes(e.type)&&(i=_(_({},i),{},(0,l.default)({},"".concat(e.type),e)))})),t._localStats=i,e(i)}))})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"displayStats",value:function(e){var t=e.stats,r=e.element,i="";Object.values(t).forEach((function(e){i+="<h2>Report: ".concat(e.type,"</h2>\n<strong>ID:</strong> ").concat(e.id,"<br>\n")+"<strong>Timestamp:</strong> ".concat(e.timestamp,"<br>\n"),Object.keys(e).forEach((function(t){"id"!==t&&"timestamp"!==t&&"type"!==t&&(i+="<strong>".concat(t,":</strong> ").concat(e[t],"<br>\n"))}))})),document.querySelector(r).innerHTML=i}},{key:"sendRequestedstats",value:(c=(0,a.default)(n.default.mark((function e(){var t;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.captureStats();case 2:t=e.sent,k.debug("Local stats are:%o",t),this.send({type:"statsFetched",stats:t});case 5:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"clientErrorHandler",value:function(e){var t=e.reason,r=e.error;this.emit("clientError",{reason:t,error:r})}},{key:"copyLink",value:function(e){navigator.clipboard.writeText(e).then((function(){k.debug("Async: Copying to clipboard was successful!"),alert("Link copied!!")}),(function(e){k.error("Async: Could not copy text:%o ",e)}))}}],[{key:"createRoom",value:(i=(0,a.default)(n.default.mark((function e(r){var i,a,s,o,c,d,u,l,f;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r.roomId,a=void 0===i?void 0:i,s=r.peerId,o=void 0===s?void 0:s,c=r.peerName,d=void 0===c?void 0:c,u=r.role,l=void 0===u?"caller":u,o||(o=(0,h.uuidv4)()),a){e.next=4;break}return e.abrupt("return",{success:!1,reason:"roomId is required!"});case 4:return f=t.env.NODE_ENV="https//cp2p.centedge.io",e.abrupt("return",new Room({peerId:o,roomId:a,peerName:d,role:l,url:f}));case 6:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})}]);var i,c,d,m,v,y,S,R,P,M,E,x,T,C,I,D,O,A,L,j}(v.EventEmitter)}).call(this)}).call(this,e("_process"))},{"../utils/getAudioVideoInputs.js":321,"../utils/getDeviceId.js":322,"../utils/getRandomInt.js":323,"../utils/gumConstraints.js":324,"../utils/sleep.js":325,"../utils/uuidv4.js":326,"./Logger.js":317,"./SocketTransport.js":319,"./platform.js":320,"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/defineProperty":27,"@babel/runtime/helpers/getPrototypeOf":28,"@babel/runtime/helpers/inherits":29,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/helpers/possibleConstructorReturn":33,"@babel/runtime/regenerator":39,_process:257,events:91}],319:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.SocketTransport=void 0;var n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator")),s=i(e("@babel/runtime/helpers/classCallCheck")),o=i(e("@babel/runtime/helpers/createClass")),c=i(e("@babel/runtime/helpers/possibleConstructorReturn")),d=i(e("@babel/runtime/helpers/getPrototypeOf")),u=i(e("@babel/runtime/helpers/inherits")),l=e("./Logger.js"),h=e("events");function f(e,t,r){return t=(0,d.default)(t),(0,c.default)(e,p()?Reflect.construct(t,r||[],(0,d.default)(e).constructor):t.apply(e,r))}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(p=function(){return!!e})()}var m=new l.Logger("socket");r.SocketTransport=function(e){function t(e){var r,i=e.url,n=e.roomId,a=e.peerId,o=e.peerName,c=e.role;return(0,s.default)(this,t),r=f(this,t),m.debug("constructor():%o ",{url:i,roomId:n,peerId:a,peerName:o,role:c}),r._closed=!1,r._params={url:i,roomId:n,peerId:a,peerName:o,role:c},r._socket=null,r._connectionStatus=null,r._createSocket(),r}return(0,u.default)(t,e),(0,o.default)(t,[{key:"closed",get:function(){return this._closed}},{key:"connectionStatus",get:function(){return this._connectionStatus}},{key:"close",value:function(){if(!this._closed){m.debug("close()"),this._closed=!0,this.emit("close");try{this._socket.disconnect()}catch(e){m.error("close() | error closing the Socket:%o",e)}}}},{key:"send",value:(c=(0,a.default)(n.default.mark((function e(t){return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._closed){e.next=2;break}throw new Error("transport closed");case 2:e.prev=2,this._socket.send(JSON.stringify(t)),e.next=10;break;case 6:throw e.prev=6,e.t0=e.catch(2),m.warn("send() failed:%o",e.t0),e.t0;case 10:case"end":return e.stop()}}),e,this,[[2,6]])}))),function(e){return c.apply(this,arguments)})},{key:"request",value:(i=(0,a.default)(n.default.mark((function e(t){var r,i,a=this;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.type,i=t.message,e.abrupt("return",new Promise((function(e){if(a._closed)throw new Error("transport closed");try{a._socket.emit(r,JSON.stringify(i),(function(t){e(t)}))}catch(e){throw m.warn("emit() failed:%o",e),e}})));case 2:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"_createSocket",value:(r=(0,a.default)(n.default.mark((function e(){var t,r;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this,(r=io(this._params.url,{query:{roomId:this._params.roomId,peerId:this._params.peerId,peerName:this._params.peerName,role:this._params.role}})).on("connect",(function(){m.debug("Socket connected!!"),t._connectionStatus=!0,t.emit("connected")})),r.on("disconnect",(function(){m.debug("Socket disconnected!!"),t._connectionStatus=!1,t.emit("disconnected")})),r.on("reconnect",(function(){m.debug("Socket reconnected after disconnect!!"),r.emit("reconnected")})),r.on("message",(function(e){var r=JSON.parse(e);m.debug("New mesage received with id:%s",r.type),t.emit("message",r)})),this._socket=r;case 7:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})}]);var r,i,c}(h.EventEmitter)},{"./Logger.js":317,"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/classCallCheck":25,"@babel/runtime/helpers/createClass":26,"@babel/runtime/helpers/getPrototypeOf":28,"@babel/runtime/helpers/inherits":29,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/helpers/possibleConstructorReturn":33,"@babel/runtime/regenerator":39,events:91}],320:[function(e,t,r){(function(i){(function(){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault")(e("@babel/runtime/helpers/typeof"));
|
|
29
|
-
/*!
|
|
30
|
-
* Platform.js
|
|
31
|
-
* Copyright 2014-2020 Benjamin Tan
|
|
32
|
-
* Copyright 2011-2013 John-David Dalton
|
|
33
|
-
* Available under MIT license
|
|
34
|
-
*/
|
|
35
|
-
(function(){var e={function:!0,object:!0},a=e["undefined"==typeof window?"undefined":(0,n.default)(window)]&&window||this,s=e[void 0===r?"undefined":(0,n.default)(r)]&&r,o=e[void 0===t?"undefined":(0,n.default)(t)]&&t&&!t.nodeType&&t,c=s&&o&&"object"==(void 0===i?"undefined":(0,n.default)(i))&&i;!c||c.global!==c&&c.window!==c&&c.self!==c||(a=c);var d=Math.pow(2,53)-1,u=/\bOpera/,l=Object.prototype,h=l.hasOwnProperty,f=l.toString;function p(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function m(e){return e=_(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:p(e)}function b(e,t){for(var r in e)h.call(e,r)&&t(e[r],r,e)}function g(e){return null==e?p(e):f.call(e).slice(8,-1)}function v(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function y(e,t){var r=null;return function(e,t){var r=-1,i=e?e.length:0;if("number"==typeof i&&i>-1&&i<=d)for(;++r<i;)t(e[r],r,e);else b(e,t)}(e,(function(i,n){r=t(r,i,n,e)})),r}function _(e){return String(e).replace(/^ +| +$/g,"")}var w=function e(t){var r=a,i=t&&"object"==(0,n.default)(t)&&"String"!=g(t);i&&(r=t,t=null);var s=r.navigator||{},o=s.userAgent||"";t||(t=o);var c,d,l,h,p,w=i?!!s.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(f.toString()),S="Object",k=i?S:"ScriptBridgingProxyObject",R=i?S:"Environment",P=i&&r.java?"JavaPackage":g(r.java),M=i?S:"RuntimeObject",E=/\bJava/.test(P)&&r.java,x=E&&g(r.environment)==R,T=E?"a":"α",C=E?"b":"β",I=r.document||{},D=r.operamini||r.opera,O=u.test(O=i&&D?D["[[Class]]"]:g(D))?O:D=null,A=t,L=[],j=null,B=t==o,N=B&&D&&"function"==typeof D.version&&D.version(),F=y([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,r){return e||RegExp("\\b"+(r.pattern||v(r))+"\\b","i").exec(t)&&(r.label||r)})),U=function(e){return y(e,(function(e,r){return e||RegExp("\\b"+(r.pattern||v(r))+"\\b","i").exec(t)&&(r.label||r)}))}(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),q=G([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),z=function(e){return y(e,(function(e,r,i){return e||(r[q]||r[/^[a-z]+(?: +[a-z]+\b)*/i.exec(q)]||RegExp("\\b"+v(i)+"(?:\\b|\\w*\\d)","i").exec(t))&&i}))}({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),V=function(e){return y(e,(function(e,r){var i=r.pattern||v(r);return!e&&(e=RegExp("\\b"+i+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,r){var i={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&r&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(i=i[/[\d.]+$/.exec(e)])&&(e="Windows "+i),e=String(e),t&&r&&(e=e.replace(RegExp(t,"i"),r)),m(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(e,i,r.label||r)),e}))}(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function G(e){return y(e,(function(e,r){var i=r.pattern||v(r);return!e&&(e=RegExp("\\b"+i+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+i+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+i+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(r.label&&!RegExp(i,"i").test(r.label)?r.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),r=r.label||r,e=m(e[0].replace(RegExp(i,"i"),r).replace(RegExp("; *(?:"+r+"[_-])?","i")," ").replace(RegExp("("+r+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function W(e){return y(e,(function(e,r){return e||(RegExp(r+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(F&&(F=[F]),/\bAndroid\b/.test(V)&&!q&&(c=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(q=_(c[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),z&&!q?q=G([z]):z&&q&&(q=q.replace(RegExp("^("+v(z)+")[-_.\\s]","i"),z+" ").replace(RegExp("^("+v(z)+")[-_.]?(\\w)","i"),z+" $2")),(c=/\bGoogle TV\b/.exec(q))&&(q=c[0]),/\bSimulator\b/i.test(t)&&(q=(q?q+" ":"")+"Simulator"),"Opera Mini"==U&&/\bOPiOS\b/.test(t)&&L.push("running in Turbo/Uncompressed mode"),"IE"==U&&/\blike iPhone OS\b/.test(t)?(z=(c=e(t.replace(/like iPhone OS/,""))).manufacturer,q=c.product):/^iP/.test(q)?(U||(U="Safari"),V="iOS"+((c=/ OS ([\d_]+)/i.exec(t))?" "+c[1].replace(/_/g,"."):"")):"Konqueror"==U&&/^Linux\b/i.test(V)?V="Kubuntu":z&&"Google"!=z&&(/Chrome/.test(U)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(q))||/\bAndroid\b/.test(V)&&/^Chrome/.test(U)&&/\bVersion\//i.test(t)?(U="Android Browser",V=/\bAndroid\b/.test(V)?V:"Android"):"Silk"==U?(/\bMobi/i.test(t)||(V="Android",L.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&L.unshift("accelerated")):"UC Browser"==U&&/\bUCWEB\b/.test(t)?L.push("speed mode"):"PaleMoon"==U&&(c=/\bFirefox\/([\d.]+)\b/.exec(t))?L.push("identifying as Firefox "+c[1]):"Firefox"==U&&(c=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(V||(V="Firefox OS"),q||(q=c[1])):!U||(c=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(U))?(U&&!q&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(c+"/")+8))&&(U=null),(c=q||z||V)&&(q||z||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(V))&&(U=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(V)?V:c)+" Browser")):"Electron"==U&&(c=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&L.push("Chromium "+c),N||(N=W(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",v(U),"(?:Firefox|Minefield|NetFront)"])),(c=("iCab"==F&&parseFloat(N)>3?"WebKit":/\bOpera\b/.test(U)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(F)&&"WebKit"||!F&&/\bMSIE\b/i.test(t)&&("Mac OS"==V?"Tasman":"Trident")||"WebKit"==F&&/\bPlayStation\b(?! Vita\b)/i.test(U)&&"NetFront")&&(F=[c]),"IE"==U&&(c=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(U+=" Mobile",V="Windows Phone "+(/\+$/.test(c)?c:c+".x"),L.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(U="IE Mobile",V="Windows Phone 8.x",L.unshift("desktop mode"),N||(N=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=U&&"Trident"==F&&(c=/\brv:([\d.]+)/.exec(t))&&(U&&L.push("identifying as "+U+(N?" "+N:"")),U="IE",N=c[1]),B){if(h="global",p=null!=(l=r)?(0,n.default)(l[h]):"number",/^(?:boolean|number|string|undefined)$/.test(p)||"object"==p&&!l[h])g(c=r.runtime)==k?(U="Adobe AIR",V=c.flash.system.Capabilities.os):g(c=r.phantom)==M?(U="PhantomJS",N=(c=c.version||null)&&c.major+"."+c.minor+"."+c.patch):"number"==typeof I.documentMode&&(c=/\bTrident\/(\d+)/i.exec(t))?(N=[N,I.documentMode],(c=+c[1]+4)!=N[1]&&(L.push("IE "+N[1]+" mode"),F&&(F[1]=""),N[1]=c),N="IE"==U?String(N[1].toFixed(1)):N[0]):"number"==typeof I.documentMode&&/^(?:Chrome|Firefox)\b/.test(U)&&(L.push("masking as "+U+" "+N),U="IE",N="11.0",F=["Trident"],V="Windows");else if(E&&(A=(c=E.lang.System).getProperty("os.arch"),V=V||c.getProperty("os.name")+" "+c.getProperty("os.version")),x){try{N=r.require("ringo/engine").version.join("."),U="RingoJS"}catch(e){(c=r.system)&&c.global.system==r.system&&(U="Narwhal",V||(V=c[0].os||null))}U||(U="Rhino")}else"object"==(0,n.default)(r.process)&&!r.process.browser&&(c=r.process)&&("object"==(0,n.default)(c.versions)&&("string"==typeof c.versions.electron?(L.push("Node "+c.versions.node),U="Electron",N=c.versions.electron):"string"==typeof c.versions.nw&&(L.push("Chromium "+N,"Node "+c.versions.node),U="NW.js",N=c.versions.nw)),U||(U="Node.js",A=c.arch,V=c.platform,N=(N=/[\d.]+/.exec(c.version))?N[0]:null));V=V&&m(V)}if(N&&(c=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(N)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(B&&s.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(j=/b/i.test(c)?"beta":"alpha",N=N.replace(RegExp(c+"\\+?$"),"")+("beta"==j?C:T)+(/\d+\+?/.exec(c)||"")),"Fennec"==U||"Firefox"==U&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(V))U="Firefox Mobile";else if("Maxthon"==U&&N)N=N.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(q))"Xbox 360"==q&&(V=null),"Xbox 360"==q&&/\bIEMobile\b/.test(t)&&L.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(U)&&(!U||q||/Browser|Mobi/.test(U))||"Windows CE"!=V&&!/Mobi/i.test(t))if("IE"==U&&B)try{null===r.external&&L.unshift("platform preview")}catch(e){L.unshift("embedded")}else(/\bBlackBerry\b/.test(q)||/\bBB10\b/.test(t))&&(c=(RegExp(q.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||N)?(V=((c=[c,/BB10/.test(t)])[1]?(q=null,z="BlackBerry"):"Device Software")+" "+c[0],N=null):this!=b&&"Wii"!=q&&(B&&D||/Opera/.test(U)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==U&&/\bOS X (?:\d+\.){2,}/.test(V)||"IE"==U&&(V&&!/^Win/.test(V)&&N>5.5||/\bWindows XP\b/.test(V)&&N>8||8==N&&!/\bTrident\b/.test(t)))&&!u.test(c=e.call(b,t.replace(u,"")+";"))&&c.name&&(c="ing as "+c.name+((c=c.version)?" "+c:""),u.test(U)?(/\bIE\b/.test(c)&&"Mac OS"==V&&(V=null),c="identify"+c):(c="mask"+c,U=O?m(O.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(c)&&(V=null),B||(N=null)),F=["Presto"],L.push(c));else U+=" Mobile";(c=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(c=[parseFloat(c.replace(/\.(\d)$/,".0$1")),c],"Safari"==U&&"+"==c[1].slice(-1)?(U="WebKit Nightly",j="alpha",N=c[1].slice(0,-1)):N!=c[1]&&N!=(c[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(N=null),c[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==c[0]&&537.36==c[2]&&parseFloat(c[1])>=28&&"WebKit"==F&&(F=["Blink"]),B&&(w||c[1])?(F&&(F[1]="like Chrome"),c=c[1]||((c=c[0])<530?1:c<532?2:c<532.05?3:c<533?4:c<534.03?5:c<534.07?6:c<534.1?7:c<534.13?8:c<534.16?9:c<534.24?10:c<534.3?11:c<535.01?12:c<535.02?"13+":c<535.07?15:c<535.11?16:c<535.19?17:c<536.05?18:c<536.1?19:c<537.01?20:c<537.11?"21+":c<537.13?23:c<537.18?24:c<537.24?25:c<537.36?26:"Blink"!=F?"27":"28")):(F&&(F[1]="like Safari"),c=(c=c[0])<400?1:c<500?2:c<526?3:c<533?4:c<534?"4+":c<535?5:c<537?6:c<538?7:c<601?8:c<602?9:c<604?10:c<606?11:c<608?12:"12"),F&&(F[1]+=" "+(c+="number"==typeof c?".x":/[.+]/.test(c)?"":"+")),"Safari"==U&&(!N||parseInt(N)>45)?N=c:"Chrome"==U&&/\bHeadlessChrome/i.test(t)&&L.unshift("headless")),"Opera"==U&&(c=/\bzbov|zvav$/.exec(V))?(U+=" ",L.unshift("desktop mode"),"zvav"==c?(U+="Mini",N=null):U+="Mobile",V=V.replace(RegExp(" *"+c+"$"),"")):"Safari"==U&&/\bChrome\b/.exec(F&&F[1])?(L.unshift("desktop mode"),U="Chrome Mobile",N=null,/\bOS X\b/.test(V)?(z="Apple",V="iOS 4.3+"):V=null):/\bSRWare Iron\b/.test(U)&&!N&&(N=W("Chrome")),N&&0==N.indexOf(c=/[\d.]+$/.exec(V))&&t.indexOf("/"+c+"-")>-1&&(V=_(V.replace(c,""))),V&&-1!=V.indexOf(U)&&!RegExp(U+" OS").test(V)&&(V=V.replace(RegExp(" *"+v(U)+" *"),"")),F&&!/\b(?:Avant|Nook)\b/.test(U)&&(/Browser|Lunascape|Maxthon/.test(U)||"Safari"!=U&&/^iOS/.test(V)&&/\bSafari\b/.test(F[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(U)&&F[1])&&(c=F[F.length-1])&&L.push(c),L.length&&(L=["("+L.join("; ")+")"]),z&&q&&q.indexOf(z)<0&&L.push("on "+z),q&&L.push((/^on /.test(L[L.length-1])?"":"on ")+q),V&&(c=/ ([\d.+]+)$/.exec(V),d=c&&"/"==V.charAt(V.length-c[0].length-1),V={architecture:32,family:c&&!d?V.replace(c[0],""):V,version:c?c[1]:null,toString:function(){var e=this.version;return this.family+(e&&!d?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(c=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(A))&&!/\bi686\b/i.test(A)?(V&&(V.architecture=64,V.family=V.family.replace(RegExp(" *"+c),"")),U&&(/\bWOW64\b/i.test(t)||B&&/\w(?:86|32)$/.test(s.cpuClass||s.platform)&&!/\bWin64; x64\b/i.test(t))&&L.unshift("32-bit")):V&&/^OS X/.test(V.family)&&"Chrome"==U&&parseFloat(N)>=39&&(V.architecture=64),t||(t=null);var H={};return H.description=t,H.layout=F&&F[0],H.manufacturer=z,H.name=U,H.prerelease=j,H.product=q,H.ua=t,H.version=U&&N,H.os=V||{architecture:null,family:null,version:null,toString:function(){return"null"}},H.parse=e,H.toString=function(){return this.description||""},H.version&&L.unshift(N),H.name&&L.unshift(U),V&&U&&(V!=String(V).split(" ")[0]||V!=U.split(" ")[0]&&!q)&&L.push(q?"("+V+")":"on "+V),L.length&&(H.description=L.join(" ")),H}();"function"==typeof define&&"object"==(0,n.default)(define.amd)&&define.amd?(a.platform=w,define((function(){return w}))):s&&o?b(w,(function(e,t){s[t]=e})):a.platform=w}).call(void 0)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/helpers/typeof":38}],321:[function(e,t,r){"use strict";var i=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.updatedDeviceList=r.chooseMediaLabel=void 0;var n=i(e("@babel/runtime/regenerator")),a=i(e("@babel/runtime/helpers/asyncToGenerator"));r.chooseMediaLabel=function(){var e=(0,a.default)(n.default.mark((function e(){var t,r;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],r=[],e.abrupt("return",navigator.mediaDevices.enumerateDevices().then((function(e){var i=void 0!==e.find((function(e){return"videoinput"===e.kind})),n=void 0!==e.find((function(e){return"audioinput"===e.kind}));return new Promise((function(e,a){navigator.mediaDevices.getUserMedia({audio:n,video:i}).then((function(i){navigator.mediaDevices.enumerateDevices().then((function(n){n.forEach((function(e){"audioinput"===e.kind&&r.push(e.label),"videoinput"===e.kind&&t.push(e.label)})),i.getTracks().forEach((function(e){e.stop()})),r.length>0&&t.length>0?e({videoLabels:t,audioLabels:r}):e({audioLabels:r,videoLabels:t})}))})).catch((function(t){console.log(t.name+": "+t.message),e({error:t.name,reason:t.message})}))}))})).catch((function(e){console.log(e.name+": "+e.message)})));case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),r.updatedDeviceList=function(){var e=(0,a.default)(n.default.mark((function e(){var t,r;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],r=[],e.abrupt("return",new Promise((function(e,i){navigator.mediaDevices.enumerateDevices().then((function(i){i.forEach((function(e){"audioinput"===e.kind&&r.push(e.label),"videoinput"===e.kind&&t.push(e.label)})),console.log(r,t),e({audioLabels:r,videoLabels:t})}))})));case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()},{"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/regenerator":39}],322:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getDeviceId=void 0;r.getDeviceId=function(e){return new Promise((function(t){navigator.mediaDevices.enumerateDevices().then((function(r){r.forEach((function(r){r.label===e&&t(r.deviceId)})),r[0].label||t({error:"noLabel",reason:"Device label names not found!"})})).catch((function(e){ConsoleHelper(e.name+": "+e.message),t({error:e.name,reason:e.message})}))}))}},{}],323:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{dup:14}],324:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.videoConstraints=r.avConstraints=r.audioConstraints=void 0;r.audioConstraints={audio:{deviceId:{exact:void 0}},video:!1},r.videoConstraints={video:{deviceId:{exact:void 0},width:{min:320,ideal:640,max:1280},height:{min:240,ideal:480,max:720},frameRate:{min:15,max:30}}},r.avConstraints={audio:!0,video:{width:{min:320,ideal:1280,max:1280},height:{min:240,ideal:720,max:720},aspectRatio:1.777777778,frameRate:{min:15,max:30}}}},{}],325:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{"@babel/runtime/helpers/asyncToGenerator":24,"@babel/runtime/helpers/interopRequireDefault":30,"@babel/runtime/regenerator":39,dup:19}],326:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20}]},{},[1])(1)}));
|
|
10
|
+
* Platform.js
|
|
11
|
+
* Copyright 2014-2020 Benjamin Tan
|
|
12
|
+
* Copyright 2011-2013 John-David Dalton
|
|
13
|
+
* Available under MIT license
|
|
14
|
+
*/(function(){var t={function:!0,object:!0},r=t[typeof window]&&window||this,s=t[typeof e]&&e,i=t[typeof module]&&module&&!module.nodeType&&module,a=s&&i&&"object"==typeof globalThis&&globalThis;!a||a.global!==a&&a.window!==a&&a.self!==a||(r=a);var n=Math.pow(2,53)-1,o=/\bOpera/,c=Object.prototype,d=c.hasOwnProperty,p=c.toString;function l(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function h(e){return e=b(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:l(e)}function u(e,t){for(var r in e)d.call(e,r)&&t(e[r],r,e)}function m(e){return null==e?l(e):p.call(e).slice(8,-1)}function f(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function g(e,t){var r=null;return function(e,t){var r=-1,s=e?e.length:0;if("number"==typeof s&&s>-1&&s<=n)for(;++r<s;)t(e[r],r,e);else u(e,t)}(e,(function(s,i){r=t(r,s,i,e)})),r}function b(e){return String(e).replace(/^ +| +$/g,"")}var _=function e(t){var s=r,i=t&&"object"==typeof t&&"String"!=m(t);i&&(s=t,t=null);var a=s.navigator||{},n=a.userAgent||"";t||(t=n);var c,d,l,_,y,w=i?!!a.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(p.toString()),v="Object",S=i?v:"ScriptBridgingProxyObject",R=i?v:"Environment",P=i&&s.java?"JavaPackage":m(s.java),C=i?v:"RuntimeObject",k=/\bJava/.test(P)&&s.java,T=k&&m(s.environment)==R,D=k?"a":"α",E=k?"b":"β",I=s.document||{},x=s.operamini||s.opera,M=o.test(M=i&&x?x["[[Class]]"]:m(x))?M:x=null,O=t,L=[],A=null,j=t==n,N=j&&x&&"function"==typeof x.version&&x.version(),B=g([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,r){return e||RegExp("\\b"+(r.pattern||f(r))+"\\b","i").exec(t)&&(r.label||r)})),F=function(e){return g(e,(function(e,r){return e||RegExp("\\b"+(r.pattern||f(r))+"\\b","i").exec(t)&&(r.label||r)}))}(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),$=V([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),U=function(e){return g(e,(function(e,r,s){return e||(r[$]||r[/^[a-z]+(?: +[a-z]+\b)*/i.exec($)]||RegExp("\\b"+f(s)+"(?:\\b|\\w*\\d)","i").exec(t))&&s}))}({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),q=function(e){return g(e,(function(e,r){var s=r.pattern||f(r);return!e&&(e=RegExp("\\b"+s+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,r){var s={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&r&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(s=s[/[\d.]+$/.exec(e)])&&(e="Windows "+s),e=String(e),t&&r&&(e=e.replace(RegExp(t,"i"),r)),h(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(e,s,r.label||r)),e}))}(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function V(e){return g(e,(function(e,r){var s=r.pattern||f(r);return!e&&(e=RegExp("\\b"+s+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+s+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+s+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(r.label&&!RegExp(s,"i").test(r.label)?r.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),r=r.label||r,e=h(e[0].replace(RegExp(s,"i"),r).replace(RegExp("; *(?:"+r+"[_-])?","i")," ").replace(RegExp("("+r+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function W(e){return g(e,(function(e,r){return e||(RegExp(r+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(B&&(B=[B]),/\bAndroid\b/.test(q)&&!$&&(c=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&($=b(c[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),U&&!$?$=V([U]):U&&$&&($=$.replace(RegExp("^("+f(U)+")[-_.\\s]","i"),U+" ").replace(RegExp("^("+f(U)+")[-_.]?(\\w)","i"),U+" $2")),(c=/\bGoogle TV\b/.exec($))&&($=c[0]),/\bSimulator\b/i.test(t)&&($=($?$+" ":"")+"Simulator"),"Opera Mini"==F&&/\bOPiOS\b/.test(t)&&L.push("running in Turbo/Uncompressed mode"),"IE"==F&&/\blike iPhone OS\b/.test(t)?(U=(c=e(t.replace(/like iPhone OS/,""))).manufacturer,$=c.product):/^iP/.test($)?(F||(F="Safari"),q="iOS"+((c=/ OS ([\d_]+)/i.exec(t))?" "+c[1].replace(/_/g,"."):"")):"Konqueror"==F&&/^Linux\b/i.test(q)?q="Kubuntu":U&&"Google"!=U&&(/Chrome/.test(F)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test($))||/\bAndroid\b/.test(q)&&/^Chrome/.test(F)&&/\bVersion\//i.test(t)?(F="Android Browser",q=/\bAndroid\b/.test(q)?q:"Android"):"Silk"==F?(/\bMobi/i.test(t)||(q="Android",L.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&L.unshift("accelerated")):"UC Browser"==F&&/\bUCWEB\b/.test(t)?L.push("speed mode"):"PaleMoon"==F&&(c=/\bFirefox\/([\d.]+)\b/.exec(t))?L.push("identifying as Firefox "+c[1]):"Firefox"==F&&(c=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(q||(q="Firefox OS"),$||($=c[1])):!F||(c=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(F))?(F&&!$&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(c+"/")+8))&&(F=null),(c=$||U||q)&&($||U||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(q))&&(F=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(q)?q:c)+" Browser")):"Electron"==F&&(c=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&L.push("Chromium "+c),N||(N=W(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",f(F),"(?:Firefox|Minefield|NetFront)"])),(c=("iCab"==B&&parseFloat(N)>3?"WebKit":/\bOpera\b/.test(F)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(B)&&"WebKit"||!B&&/\bMSIE\b/i.test(t)&&("Mac OS"==q?"Tasman":"Trident")||"WebKit"==B&&/\bPlayStation\b(?! Vita\b)/i.test(F)&&"NetFront")&&(B=[c]),"IE"==F&&(c=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(F+=" Mobile",q="Windows Phone "+(/\+$/.test(c)?c:c+".x"),L.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(F="IE Mobile",q="Windows Phone 8.x",L.unshift("desktop mode"),N||(N=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=F&&"Trident"==B&&(c=/\brv:([\d.]+)/.exec(t))&&(F&&L.push("identifying as "+F+(N?" "+N:"")),F="IE",N=c[1]),j){if(_="global",y=null!=(l=s)?typeof l[_]:"number",/^(?:boolean|number|string|undefined)$/.test(y)||"object"==y&&!l[_])m(c=s.runtime)==S?(F="Adobe AIR",q=c.flash.system.Capabilities.os):m(c=s.phantom)==C?(F="PhantomJS",N=(c=c.version||null)&&c.major+"."+c.minor+"."+c.patch):"number"==typeof I.documentMode&&(c=/\bTrident\/(\d+)/i.exec(t))?(N=[N,I.documentMode],(c=+c[1]+4)!=N[1]&&(L.push("IE "+N[1]+" mode"),B&&(B[1]=""),N[1]=c),N="IE"==F?String(N[1].toFixed(1)):N[0]):"number"==typeof I.documentMode&&/^(?:Chrome|Firefox)\b/.test(F)&&(L.push("masking as "+F+" "+N),F="IE",N="11.0",B=["Trident"],q="Windows");else if(k&&(O=(c=k.lang.System).getProperty("os.arch"),q=q||c.getProperty("os.name")+" "+c.getProperty("os.version")),T){try{N=s.require("ringo/engine").version.join("."),F="RingoJS"}catch(H){(c=s.system)&&c.global.system==s.system&&(F="Narwhal",q||(q=c[0].os||null))}F||(F="Rhino")}else"object"==typeof s.process&&!s.process.browser&&(c=s.process)&&("object"==typeof c.versions&&("string"==typeof c.versions.electron?(L.push("Node "+c.versions.node),F="Electron",N=c.versions.electron):"string"==typeof c.versions.nw&&(L.push("Chromium "+N,"Node "+c.versions.node),F="NW.js",N=c.versions.nw)),F||(F="Node.js",O=c.arch,q=c.platform,N=(N=/[\d.]+/.exec(c.version))?N[0]:null));q=q&&h(q)}if(N&&(c=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(N)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(j&&a.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(A=/b/i.test(c)?"beta":"alpha",N=N.replace(RegExp(c+"\\+?$"),"")+("beta"==A?E:D)+(/\d+\+?/.exec(c)||"")),"Fennec"==F||"Firefox"==F&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(q))F="Firefox Mobile";else if("Maxthon"==F&&N)N=N.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test($))"Xbox 360"==$&&(q=null),"Xbox 360"==$&&/\bIEMobile\b/.test(t)&&L.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(F)&&(!F||$||/Browser|Mobi/.test(F))||"Windows CE"!=q&&!/Mobi/i.test(t))if("IE"==F&&j)try{null===s.external&&L.unshift("platform preview")}catch(H){L.unshift("embedded")}else(/\bBlackBerry\b/.test($)||/\bBB10\b/.test(t))&&(c=(RegExp($.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||N)?(q=((c=[c,/BB10/.test(t)])[1]?($=null,U="BlackBerry"):"Device Software")+" "+c[0],N=null):this!=u&&"Wii"!=$&&(j&&x||/Opera/.test(F)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==F&&/\bOS X (?:\d+\.){2,}/.test(q)||"IE"==F&&(q&&!/^Win/.test(q)&&N>5.5||/\bWindows XP\b/.test(q)&&N>8||8==N&&!/\bTrident\b/.test(t)))&&!o.test(c=e.call(u,t.replace(o,"")+";"))&&c.name&&(c="ing as "+c.name+((c=c.version)?" "+c:""),o.test(F)?(/\bIE\b/.test(c)&&"Mac OS"==q&&(q=null),c="identify"+c):(c="mask"+c,F=M?h(M.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(c)&&(q=null),j||(N=null)),B=["Presto"],L.push(c));else F+=" Mobile";(c=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(c=[parseFloat(c.replace(/\.(\d)$/,".0$1")),c],"Safari"==F&&"+"==c[1].slice(-1)?(F="WebKit Nightly",A="alpha",N=c[1].slice(0,-1)):N!=c[1]&&N!=(c[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(N=null),c[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==c[0]&&537.36==c[2]&&parseFloat(c[1])>=28&&"WebKit"==B&&(B=["Blink"]),j&&(w||c[1])?(B&&(B[1]="like Chrome"),c=c[1]||((c=c[0])<530?1:c<532?2:c<532.05?3:c<533?4:c<534.03?5:c<534.07?6:c<534.1?7:c<534.13?8:c<534.16?9:c<534.24?10:c<534.3?11:c<535.01?12:c<535.02?"13+":c<535.07?15:c<535.11?16:c<535.19?17:c<536.05?18:c<536.1?19:c<537.01?20:c<537.11?"21+":c<537.13?23:c<537.18?24:c<537.24?25:c<537.36?26:"Blink"!=B?"27":"28")):(B&&(B[1]="like Safari"),c=(c=c[0])<400?1:c<500?2:c<526?3:c<533?4:c<534?"4+":c<535?5:c<537?6:c<538?7:c<601?8:c<602?9:c<604?10:c<606?11:c<608?12:"12"),B&&(B[1]+=" "+(c+="number"==typeof c?".x":/[.+]/.test(c)?"":"+")),"Safari"==F&&(!N||parseInt(N)>45)?N=c:"Chrome"==F&&/\bHeadlessChrome/i.test(t)&&L.unshift("headless")),"Opera"==F&&(c=/\bzbov|zvav$/.exec(q))?(F+=" ",L.unshift("desktop mode"),"zvav"==c?(F+="Mini",N=null):F+="Mobile",q=q.replace(RegExp(" *"+c+"$"),"")):"Safari"==F&&/\bChrome\b/.exec(B&&B[1])?(L.unshift("desktop mode"),F="Chrome Mobile",N=null,/\bOS X\b/.test(q)?(U="Apple",q="iOS 4.3+"):q=null):/\bSRWare Iron\b/.test(F)&&!N&&(N=W("Chrome")),N&&0==N.indexOf(c=/[\d.]+$/.exec(q))&&t.indexOf("/"+c+"-")>-1&&(q=b(q.replace(c,""))),q&&-1!=q.indexOf(F)&&!RegExp(F+" OS").test(q)&&(q=q.replace(RegExp(" *"+f(F)+" *"),"")),B&&!/\b(?:Avant|Nook)\b/.test(F)&&(/Browser|Lunascape|Maxthon/.test(F)||"Safari"!=F&&/^iOS/.test(q)&&/\bSafari\b/.test(B[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(F)&&B[1])&&(c=B[B.length-1])&&L.push(c),L.length&&(L=["("+L.join("; ")+")"]),U&&$&&$.indexOf(U)<0&&L.push("on "+U),$&&L.push((/^on /.test(L[L.length-1])?"":"on ")+$),q&&(c=/ ([\d.+]+)$/.exec(q),d=c&&"/"==q.charAt(q.length-c[0].length-1),q={architecture:32,family:c&&!d?q.replace(c[0],""):q,version:c?c[1]:null,toString:function(){var e=this.version;return this.family+(e&&!d?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(c=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(O))&&!/\bi686\b/i.test(O)?(q&&(q.architecture=64,q.family=q.family.replace(RegExp(" *"+c),"")),F&&(/\bWOW64\b/i.test(t)||j&&/\w(?:86|32)$/.test(a.cpuClass||a.platform)&&!/\bWin64; x64\b/i.test(t))&&L.unshift("32-bit")):q&&/^OS X/.test(q.family)&&"Chrome"==F&&parseFloat(N)>=39&&(q.architecture=64),t||(t=null);var K={};return K.description=t,K.layout=B&&B[0],K.manufacturer=U,K.name=F,K.prerelease=A,K.product=$,K.ua=t,K.version=F&&N,K.os=q||{architecture:null,family:null,version:null,toString:function(){return"null"}},K.parse=e,K.toString=function(){return this.description||""},K.version&&L.unshift(N),K.name&&L.unshift(F),q&&F&&(q!=String(q).split(" ")[0]||q!=F.split(" ")[0]&&!$)&&L.push($?"("+q+")":"on "+q),L.length&&(K.description=L.join(" ")),K}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(r.platform=_,define((function(){return _}))):s&&i?u(_,(function(e,t){s[t]=e})):r.platform=_}).call(void 0);const qn=new jn("Room");class Vn extends Wt.EventEmitter{static async createRoom({roomId:e,peerId:t,peerName:r,role:s="caller"}){if(t||(t="111-111-1111".replace(/[018]/g,(()=>(15&crypto.getRandomValues(new Uint8Array(1))[0]).toString(16)))),!e)return{success:!1,reason:"roomId is required!"};const i=process.env.NODE_ENV="https//cp2p.centedge.io";return new Room({peerId:t,roomId:e,peerName:r,role:s,url:i})}constructor({peerId:e,roomId:t,peerName:r,role:s,url:i}){super(),this._closed=!1,this._roomId=t,this._socket=null,this._peerConnection=null,this._myDisplayName=r,this._myPeerId=e,this._myRole=s,this._localStream=null,this._remoteDisplayName=null,this._remotePeerId=null,this._remoteRole=null,this._remoteStream=null,this._canvas=null,this._imageData=null,this._imageWidth=1280,this._imageHeight=720,this._availableMediaInputs=null,this._userAgent={name:platform.name,version:platform.version,os:platform.os.family,description:platform.description},this._remoteMediaInputs=null,this._remoteUserAgent=null,this._statsCaptureInterval=null,this._localStats=null,this._remoteStats=null,this._otherPeerConnected=null,this._data={},this._url=i,this.prepareForCall(),qn.debug("user agent is:%o",this._userAgent)}get imageData(){return this._imageData}get roomId(){return this._roomId}get localStream(){return this._localStream}get remoteStream(){return this._remoteStream}get myName(){return this._myDisplayName}set myName(e){this._myDisplayName=e}get myId(){return this._myPeerId}get myRole(){return this._myRole}get remoteName(){return this._remoteDisplayName}get remoteId(){return this._remotePeerId}get remoteRole(){return this._remoteRole}get imageHeight(){return this._imageHeight}get imageWidth(){return this._imageWidth}get userAgent(){return this._userAgent}get mediaInputs(){return this._availableMediaInputs}get remoteUserAgent(){return this._remoteUserAgent}get remoteMediaInputs(){return this._remoteMediaInputs}get localStats(){return this._localStats}get remoteStats(){return this._remoteStats}get pc(){return this._peerConnection}get data(){return this._data}set data(e){throw new Error("Can't set the whole of data object.")}setImageProps({width:e,height:t}){e&&t?(this._imageHeight=t,this._imageWidth=e):this.clientErrorHandler({reason:"Both width and height are required to set the new image properties. ",error:null})}async prepareForCall(){let e=this;(async()=>{let e=[],t=[];return navigator.mediaDevices.enumerateDevices().then((function(r){let s=void 0!==r.find((e=>"videoinput"===e.kind)),i=void 0!==r.find((e=>"audioinput"===e.kind));return new Promise(((r,a)=>{navigator.mediaDevices.getUserMedia({audio:i,video:s}).then((s=>{navigator.mediaDevices.enumerateDevices().then((function(i){i.forEach((function(r){"audioinput"===r.kind&&t.push(r.label),"videoinput"===r.kind&&e.push(r.label)})),s.getTracks().forEach((e=>{e.stop()})),t.length>0&&e.length>0?r({videoLabels:e,audioLabels:t}):r({audioLabels:t,videoLabels:e})}))})).catch((function(e){r({error:e.name,reason:e.message})}))}))})).catch((function(e){}))})().then((async t=>{if(t.error)switch(t.error){case"NotAllowedError":let e=`${t.error} : ${t.reason}!! You have denied the access to your Mic!! If you wish to join the room with video, please allow the camera access by clicking on the camera icon in the address bar Or by going to " chrome://settings/content#media-stream-mic " link in your chrome.`;this.clientErrorHandler({reason:e,error:null});break;case"NotFoundError":let r=`${t.error} : ${t.reason}!! No Microphone could be found!! If you have a camera or microphone in your computer but it is not able to detect them, please refresh your browser again or restart the browser after closing all the opened tabs.`;this.clientErrorHandler({reason:r,error:null});break;case"NotReadableError":let s=`${t.error} : ${t.reason}!! A hardware error occured at the OS OR browser Or Webpage level. If you have a microphone in your computer but it is not able to detect them, please refresh your browser again or restart the browser after closing all the opened tabs.`;this.clientErrorHandler({reason:s,error:null})}else t.audioLabels&&t.audioLabels.length>0&&t.videoLabels&&t.videoLabels.length>0&&(e._availableMediaInputs={audioInputs:t.audioLabels,videoInputs:t.videoLabels},qn.debug("available A/V inputs:%o",e.mediaInputs),await e.getUserMedia(),e.emit("mediaInputs"))})),navigator.mediaDevices.ondevicechange=async t=>{qn.info("Media devices changed!");let r=await(async()=>{let e=[],t=[];return new Promise(((r,s)=>{navigator.mediaDevices.enumerateDevices().then((function(s){s.forEach((r=>{"audioinput"===r.kind&&t.push(r.label),"videoinput"===r.kind&&e.push(r.label)})),r({audioLabels:t,videoLabels:e})}))}))})();r.audioLabels&&r.audioLabels.length>0&&r.videoLabels&&r.videoLabels.length>0&&(e._availableMediaInputs={audioInputs:r.audioLabels,videoInputs:r.videoLabels},qn.debug("updated A/V inputs:%o",e.mediaInputs),e.emit("mediaInputs"),"client"===e.myRole&&e.pc&&(qn.info("Going to update the agent about the updated media devices list."),e.send({type:"mediaListUpdated",mediaInputs:e.mediaInputs})))}}send(e){this._closed||this._socket.send(e)}inform(e){if(this._closed)return;let t={type:"information",msg:e};this._socket.send(t)}async request({type:e,message:t}){const r=await this._socket.request({type:e,message:t});if(r)return r}gotMessageFromServer(e){switch(qn.debug("Got message:%o",e),e.type){case"login":this.handleLogin(e.details);break;case"offer":qn.debug("inside offer"),this.handleOffer({offer:e.offer,peer:e.peer,name:e.name});break;case"answer":qn.debug("inside answer"),this.handleAnswer(e);break;case"candidate":qn.debug("inside handle candidate"),this.handleCandidate(e.candidate);break;case"leave":this.handleLeave(),this.emit("peerHangUp");break;case"audioToggle":this.emit("audioToggle",{status:e.status,peer:"other"});break;case"videoToggle":this.emit("videoToggle",{status:e.status,peer:"other"});break;case"remoteStreamToggle":this.handleRemoteStreamToggle(e);break;case"chatMessage":this.emit("chatMessage",e.message);break;case"imageCapture":this.captureImage("local");break;case"mediaChange":this.changeRemoteMediaSource(e);break;case"requestStats":this.sendRequestedstats();break;case"statsFetched":this._remoteStats=e.stats,this.emit("remoteStats");break;case"information":this.emit("information",e.msg);break;case"iceRestart":this.handleIceRestart(e);break;case"iceRestarted":this.handleIceRestartResponse(e);break;case"nameUpdate":this._remoteDisplayName=e.name,this.emit("peerName");break;case"mediaListUpdated":this._remoteMediaInputs=e.mediaInputs,this.emit("remoteMediaInputs");break;case"peerLeft":this.pc||(this._remoteDisplayName=null,this._remotePeerId=null,this._remoteRole=null,this._otherPeerConnected=!1,this.emit("peerJoin","None"),alert("Other person disconnected from the room"));break;case"error":this.emit("serverError",e.details)}}async getUserMedia(){qn.debug("Inside getusermedia"),this._localStream?qn.debug("Local stream already acquired! Waiting for call!"):navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia(Fn).then((e=>this.getUserMediaSuccess(e))).catch((e=>this.clientErrorHandler({reason:"Error while acquiring camera/mic",error:e}))):alert("Your browser does not support getUserMedia API")}getUserMediaSuccess(e){let t=this;qn.debug("Inside getUserMediaSuccess"),this._localStream=e,this.emit("localStream"),this._socket=new Un({url:this._url,roomId:this._roomId,peerId:this._myPeerId,peerName:this._myDisplayName,role:this._myRole}),this._socket.on("message",(e=>this.gotMessageFromServer(e))),this._socket.on("connected",(async()=>{t.pc&&(qn.debug("Socket reconnection happened after a disconnection, ICEState:%s",t._peerConnection.iceConnectionState),"failed"!==t._peerConnection.iceConnectionState&&"disconnected"!==t._peerConnection.iceConnectionState||(qn.debug("Going to restart ICE as ICE is not in connected state!!"),await t.restartICE()))}))}handleAudioToggle(){let e=this._localStream.getAudioTracks()[0];e.enabled=!e.enabled,this.send({type:"audioToggle",status:e.enabled}),this.emit("audioToggle",{status:e.enabled,peer:"self"})}handleVideoToggle(){let e=this._localStream.getVideoTracks()[0];e.enabled=!e.enabled,this.send({type:"videoToggle",status:e.enabled}),this.emit("videoToggle",{status:e.enabled,peer:"self"})}handleVideoToggleNew(){let e=this;if(this._peerConnection){const t=this._peerConnection.getSenders().find((function(e){return e.track&&"video"==e.track.kind}));if(t){qn.debug("found sender:%o",t),this._peerConnection.removeTrack(t);let e=this._localStream.getVideoTracks()[0];e&&(e.stop(),this._localStream.removeTrack(e)),this.send({type:"videoToggle",status:!1}),this.emit("videoToggle",{status:!1,peer:"self"})}else qn.debug("sender not found. Going to create a new video track."),navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia({...Fn,audio:!1}).then((t=>{let r=t.getVideoTracks()[0];e._localStream.addTrack(r),e._peerConnection.addTrack(r),e.send({type:"videoToggle",status:!0}),e.emit("localStream"),e.emit("videoToggle",{status:!0,peer:"self"})})).catch((e=>this.clientErrorHandler({reason:"Error while acquiring camera/mic",error:e}))):alert("Your browser does not support getUserMedia API")}else qn.warn("Peer connection not found!")}handleRemoteAudioToggle(){this.send({type:"remoteStreamToggle",streamType:"audio"})}handleRemoteVideoToggle(){this.send({type:"remoteStreamToggle",streamType:"video"})}handleRemoteStreamToggle(e){qn.debug("inside remote stream toggle"),"audio"===e.streamType?this.handleAudioToggle():"video"===e.streamType?this.handleVideoToggle():qn.warn("Invalid stream type!")}sendChatMessage(e){e&&" "!==e?this.send({type:"chatMessage",message:e}):this.clientErrorHandler({reason:"Chat message need to have a valid value!",error:null})}async informPeer(){this.remoteId&&this.send({type:"nameUpdate",name:this.myName})}handleLogin(e){e&&(qn.debug("All available users:%o",e),this._remoteDisplayName=e.displayName,this._remotePeerId=e.peerId,this._remoteRole=e.role),this._otherPeerConnected=!0,this.emit("peerJoin",this._remoteDisplayName)}async gotRemoteTrack(e){qn.debug("inside got remote track:%o",e),e.streams&&e.streams[0]?(qn.debug("Got a remote stream"),this._remoteStream=e.streams[0]):(this._remoteStream=new MediaStream,this._remoteStream.addTrack(e.track),qn.debug("Got a remote track")),this.emit("remoteStream")}_onICeCandidate(e){qn.debug("onicecandidate",e.candidate),e.candidate&&this.send({type:"candidate",candidate:e.candidate,peer:this._remotePeerId})}handleNegotiationNeededEvent=()=>{qn.debug("handleNegotiationNeededEvent() | needed to negotiate a new negotiation"),this.restartICE()};handleRemoveTrackEvent=()=>{qn.debug("handleRemoveTrackEvent() | Track removed by remote peer. Need to handle UI locally."),this.emit("videoToggle",{status:!1,peer:"other"})};async createPeerOffer(e){let t,r=this;t=await this._socket.request({type:"fetchIceServers",message:{}}),this._peerConnection=new RTCPeerConnection({iceServers:t}),qn.debug("connection state in createPeeroffer():%s",this._peerConnection.connectionState),this._peerConnection.onicecandidate=e=>{this._onICeCandidate(e)},this._localStream.getTracks().forEach((e=>this._peerConnection.addTrack(e,this._localStream)));const s=await this._peerConnection.createOffer().catch((function(e){alert("Error when creating an offer",e),qn.error("Error when creating an offer:%o",e)}));await this._peerConnection.setLocalDescription(s),this.send({type:"offer",offer:r._peerConnection.localDescription,peer:r._remotePeerId,name:r.myName}),this._peerConnection.ontrack=e=>r.gotRemoteTrack(e),this._peerConnection.addEventListener("iceconnectionstatechange",(async e=>{qn.debug("Current ICEState:%s",r._peerConnection.iceConnectionState),"failed"!==r._peerConnection.iceConnectionState&&"disconnected"!==r._peerConnection.iceConnectionState||(qn.debug("Ice connection failed!! with socket connection status:%s",r._socket.connectionStatus),r.emit("iceFailure"))})),this._peerConnection.onnegotiationneeded=()=>this.handleNegotiationNeededEvent(),this._peerConnection.onremovetrack=()=>this.handleRemoveTrackEvent()}async handleOffer({peer:e,name:t,offer:r}){let s=this;const i=await this._socket.request({type:"fetchIceServers",message:{}});this._peerConnection=new RTCPeerConnection({iceServers:i}),qn.debug("Peer connection in handle offer is:%s",this._peerConnection),this._remoteDisplayName=t,this._remotePeerId=e,this._peerConnection.setRemoteDescription(new RTCSessionDescription(r)),this._localStream.getTracks().forEach((e=>this._peerConnection.addTrack(e,this._localStream))),this._peerConnection.createAnswer().then((function(e){return s._peerConnection.setLocalDescription(e)})).then((function(){qn.debug("Ice already completed. sending answer!!"),s.send({type:"answer",answer:s._peerConnection.localDescription,peer:s._remotePeerId,mediaInputs:s.mediaInputs,userAgent:s.userAgent})})).catch((function(e){alert("Error when creating an answer"),qn.error("Error while creating answer:%o",e)})),this._peerConnection.ontrack=e=>s.gotRemoteTrack(e),this._peerConnection.onicecandidate=e=>{this._onICeCandidate(e)},this._peerConnection.addEventListener("iceconnectionstatechange",(async e=>{qn.debug("Current ICEState:%s",s._peerConnection.iceConnectionState),"failed"!==s._peerConnection.iceConnectionState&&"disconnected"!==s._peerConnection.iceConnectionState||(qn.debug("Ice connection failed!! with socket connection status:%s",s._socket.connectionStatus),s.emit("iceFailure"))})),this._peerConnection.onnegotiationneeded=()=>this.handleNegotiationNeededEvent(),this._peerConnection.onremovetrack=()=>this.handleRemoveTrackEvent(),this.emit("offerReceived")}handleAnswer(e){qn.debug("answer:%o ",e),this._peerConnection.setRemoteDescription(new RTCSessionDescription(e.answer)),this._remoteMediaInputs=e.mediaInputs,this._remoteUserAgent=e.userAgent,this.emit("remoteMediaInputs")}async handleCandidate(e){this.pc?(qn.debug("Peerconnection available, Inside handle candidate for remote icecandidates"),this._peerConnection.addIceCandidate(new RTCIceCandidate(e)).catch((e=>{qn.error("Error while adding iceCandidate",e)}))):qn.warn("Candidate arrived before peer connection instantiation:%o",e)}async restartICE(){const e=await this._peerConnection.createOffer({iceRestart:!0});await this._peerConnection.setLocalDescription(e),this.send({type:"iceRestart",offer:e})}async handleIceRestart(e){qn.debug("Ice restart message received!!"),this._peerConnection.setRemoteDescription(e.offer);const t=await this._peerConnection.createAnswer();await this._peerConnection.setLocalDescription(t),this.send({type:"iceRestarted",answer:t})}async handleIceRestartResponse(e){qn.debug("Ice restart message response received!!"),this._peerConnection.setRemoteDescription(e.answer)}async informRoomLeave(){this.send({type:"leave",peer:this.remoteId}),await this.handleLeave()}async handleLeave(){this._peerConnection?(this._peerConnection.ontrack=null,this._peerConnection.onremovetrack=null,this._peerConnection.onremovestream=null,this._peerConnection.onicecandidate=null,this._peerConnection.oniceconnectionstatechange=null,this._peerConnection.onsignalingstatechange=null,this._peerConnection.onicegatheringstatechange=null,this._peerConnection.onnegotiationneeded=null,this._localStream&&this._localStream.getTracks().forEach((e=>e.stop())),this._remoteStream&&this._remoteStream.getTracks().forEach((e=>e.stop())),this._peerConnection.close(),this._peerConnection=null,this._remoteDisplayName=null,this._remotePeerId=null,this._remoteStream=null,this._localStream=null,this._canvas=null,this._imageData=null,this._imageWidth=640,this._imageHeight=480,this._socket.close()):qn.error("No peerconnection object found!")}async changeRemoteMediaSource(e){let{label:t,mediaType:r}=e;!t||"video"!==r&&"audio"!==r?this.send({type:"error",details:{reason:"Can't change remote media source as either media label or media type is not available!"}}):this.handleReplaceTrack({label:t,mediaType:r})}async handleReplaceTrack({label:e,mediaType:t}){try{let r,s,i;const a=await(e=>new Promise((t=>{navigator.mediaDevices.enumerateDevices().then((function(r){r.forEach((function(r){r.label===e&&t(r.deviceId)})),r[0].label||t({error:"noLabel",reason:"Device label names not found!"})})).catch((function(e){ConsoleHelper(e.name+": "+e.message),t({error:e.name,reason:e.message})}))})))(e);"video"===t?(Bn.video.deviceId.exact=a,i=Bn,r=this._localStream.getVideoTracks()[0]):"audio"===t?(Nn.audio.deviceId.exact=a,i=Nn,r=this._localStream.getAudioTracks()[0]):qn.error("Unknown media type:%s",t);let n=r.enabled;r.stop(),qn.debug("selected constraints are:%o",i);let o=await navigator.mediaDevices.getUserMedia(i);if(qn.debug("new stream is:%o",o),"video"===t?s=o.getVideoTracks()[0]:"audio"===t&&(s=o.getAudioTracks()[0]),s.enabled=n,this._peerConnection){const e=this._peerConnection.getSenders().find((function(e){return e.track.kind==s.kind}));qn.debug("found sender:%o",e),e.replaceTrack(s)}this._localStream.removeTrack(r),this._localStream.addTrack(s)}catch(r){qn.error("Error while replace media track:%o",r),this.clientErrorHandler({reason:"Error while replacing media track with new source",error:r})}}async captureImage(e){const t=document.createElement("canvas"),r=t.getContext("2d"),s=this._imageWidth,i=this._imageHeight;qn.debug("height:%s and width:%s",s,i),t.width=s,t.height=i,"local"===e?r.drawImage(localVideo,0,0,s,i):r.drawImage(remoteVideo,0,0,s,i);let a=t.toDataURL("image/png");this._canvas=t,this._imageData=a,this.emit("imageCaptured")}async clearImage(){const e=this._canvas,t=e.getContext("2d");t.fillStyle="#AAA",t.fillRect(0,0,e.width,e.height);let r=e.toDataURL("image/png");this._imageData=r}captureRemoteImage(){this.send({type:"imageCapture"})}remoteCamChange(e){e?this.send({type:"mediaChange",mediaType:"video",label:e}):this.clientErrorHandler({reason:"A valid camera name must be selected for to change the remote camera!",error:null})}remoteMicChange(e){e?this.send({type:"mediaChange",mediaType:"audio",label:e}):this.clientErrorHandler({reason:"A valid mic name must be selected for to change the remote mic!",error:null})}requestStats(){this.send({type:"requestStats"})}async captureStats(){let e=this;return new Promise((t=>{this._peerConnection.getStats(null).then((r=>{let s={};r.forEach((e=>{["inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","local-candidate","remote-candidate","candidate-pair"].includes(e.type)&&(s={...s,[`${e.type}`]:e})})),e._localStats=s,t(s)}))}))}displayStats({stats:e,element:t}){let r="";Object.values(e).forEach((e=>{r+=`<h2>Report: ${e.type}</h2>\n<strong>ID:</strong> ${e.id}<br>\n<strong>Timestamp:</strong> ${e.timestamp}<br>\n`,Object.keys(e).forEach((t=>{"id"!==t&&"timestamp"!==t&&"type"!==t&&(r+=`<strong>${t}:</strong> ${e[t]}<br>\n`)}))})),document.querySelector(t).innerHTML=r}async sendRequestedstats(){let e=await this.captureStats();qn.debug("Local stats are:%o",e),this.send({type:"statsFetched",stats:e})}clientErrorHandler({reason:e,error:t}){this.emit("clientError",{reason:e,error:t})}copyLink(e){navigator.clipboard.writeText(e).then((function(){qn.debug("Async: Copying to clipboard was successful!"),alert("Link copied!!")}),(function(e){qn.error("Async: Could not copy text:%o ",e)}))}}const Wn={JsSdk_v1:La,JsSdk:Ln,P2pSdk:Vn};e.JsSdk=Ln,e.JsSdk_v1=La,e.P2pSdk=Vn,e.default=Wn,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|