1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6398],{46398:function(e,t,n){"use strict";t.AS=t.Ig=void 0;var r=n(22534);t.Ig=r.default;var i=n(65718);t.AS=i.default,n(12861),n(92764),n(7562)},24548:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncQueue=void 0;var o=n(42721),a=function(){function e(){this._operations=[]}return e.prototype.enqueue=function(e){var t=!!this._operations.length,n=new o.default;return this._operations.push({deferred:n,callback:e}),t||this._processQueue(),n.promise},e.prototype._processQueue=function(){return r(this,void 0,void 0,function(){var e,t,n,r,o,a;return i(this,function(i){switch(i.label){case 0:if(!this._operations.length)return[3,5];t=(e=this._operations[0]).deferred,n=e.callback,r=void 0,o=void 0,a=void 0,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n()];case 2:return r=i.sent(),a=!0,[3,4];case 3:return o=i.sent(),[3,4];case 4:return this._operations.shift(),a?t.resolve(r):t.reject(o),[3,0];case 5:return[2]}})})},e}();t.AsyncQueue=a},20407:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};
1Object.defineProperty(t,"__esModule",{value:!0});var s=n(55445),c=n(65718),u=n(12861),d=n(92764),l=n(37244),p=n(14186),f=n(41262),h={audioinput:"Audio Input",audiooutput:"Audio Output"},m=function(e){function t(t,n,r){var i,o=e.call(this)||this;o.availableInputDevices=new Map,o.availableOutputDevices=new Map,o._audioConstraints=null,o._defaultInputDeviceStream=null,o._enabledSounds=((i={})[c.default.SoundName.Disconnect]=!0,i[c.default.SoundName.Incoming]=!0,i[c.default.SoundName.Outgoing]=!0,i),o._inputDevice=null,o._inputDevicePromise=null,o._isPollingInputVolume=!1,o._log=new d.default("AudioHelper"),o._processedStream=null,o._selectedInputDeviceStream=null,o._unknownDeviceIndexes={audioinput:{},audiooutput:{}},o._updateAvailableDevices=function(){return o._mediaDevices&&o._enumerateDevices?o._enumerateDevices().then(function(e){o._updateDevices(e.filter(function(e){return"audiooutput"===e.kind}),o.availableOutputDevices,o._removeLostOutput),o._updateDevices(e.filter(function(e){return"audioinput"===e.kind}),o.availableInputDevices,o._removeLostInput);var t=o.availableOutputDevices.get("default")||Array.from(o.availableOutputDevices.values())[0];[o.speakerDevices,o.ringtoneDevices].forEach(function(e){!e.get().size&&o.availableOutputDevices.size&&o.isOutputSelectionSupported&&e.set(t.deviceId).catch(function(e){o._log.warn("Unable to set audio output devices. "+e)})})}):Promise.reject("Enumeration not supported")},o._removeLostInput=function(e){if(!o.inputDevice||o.inputDevice.deviceId!==e.deviceId)return!1;o._destroyProcessedStream(),o._replaceStream(null),o._inputDevice=null,o._maybeStopPollingVolume();var t=o.availableInputDevices.get("default")||Array.from(o.availableInputDevices.values())[0];return t&&o.setInputDevice(t.deviceId),!0},o._removeLostOutput=function(e){var t=o.speakerDevices.delete(e),n=o.ringtoneDevices.delete(e);return t||n},r=Object.assign({AudioContext:"undefined"!=typeof AudioContext&&AudioContext,setSinkId:"undefined"!=typeof HTMLAudioElement&&HTMLAudioElement.prototype.setSinkId},r),o._beforeSetInputDevice=r.beforeSetInputDevice||function(){return Promise.resolve()},o._updateUserOptions(r),o._audioProcessorEventObserver=r.audioProcessorEventObserver,o._mediaDevices=r.mediaDevices||navigator.mediaDevices,o._onActiveInputChanged=n,o._enumerateDevices="function"==typeof r.enumerateDevices?r.enumerateDevices:o._mediaDevices&&o._mediaDevices.enumerateDevices.bind(o._mediaDevices);var a=!!(r.AudioContext||r.audioContext),s=!!o._enumerateDevices;r.enabledSounds&&(o._enabledSounds=r.enabledSounds);var u="function"==typeof r.setSinkId;return o.isOutputSelectionSupported=s&&u,o.isVolumeSupported=a,o.isVolumeSupported&&(o._audioContext=r.audioContext||r.AudioContext&&new r.AudioContext,o._audioContext&&(o._inputVolumeAnalyser=o._audioContext.createAnalyser(),o._inputVolumeAnalyser.fftSize=32,o._inputVolumeAnalyser.smoothingTimeConstant=.3)),o.ringtoneDevices=new l.default("ringtone",o.availableOutputDevices,t,o.isOutputSelectionSupported),o.speakerDevices=new l.default("speaker",o.availableOutputDevices,t,o.isOutputSelectionSupported),o.addListener("newListener",function(e){"inputVolume"===e&&o._maybeStartPollingVolume()}),o.addListener("removeListener",function(e){"inputVolume"===e&&o._maybeStopPollingVolume()}),o.once("newListener",function(){o.isOutputSelectionSupported||o._log.warn("Warning: This browser does not support audio output selection."),o.isVolumeSupported||o._log.warn("Warning: This browser does not support Twilio's volume indicator feature.")}),s&&o._initializeEnumeration(),navigator&&navigator.permissions&&"function"==typeof navigator.permissions.query?navigator.permissions.query({name:"microphone"}).then(function(e){if("granted"!==e.state){var t=function(){o._updateAvailableDevices(),o._stopMicrophonePermissionListener()};e.addEventListener("change",t),o._microphonePermissionStatus=e,o._onMicrophonePermissionStatusChanged=t}}).catch(function(e){return o._log.warn("Warning: unable to listen for microphone permission changes. "+e)}):o._log.warn("Warning: current browser does not support permissions API."),o}return i(t,e),Object.defineProperty(t.prototype,"audioConstraints",{get:function(){return this._audioConstraints}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inputDevice",{get:function(){return this._inputDevice},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inputStream",{get:function(){return this._processedStream||this._selectedInputDeviceStream},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"processedStream",{get:function(){return this._processedStream},enumerable:!1,configurable:!0}),t.prototype._destroy=function(){this._stopDefaultInputDeviceStream(),this._stopSelectedInputDeviceStream(),this._destroyProcessedStream(),this._maybeStopPollingVolume(),this.removeAllListeners(),this._stopMicrophonePermissionListener(),this._unbind()},t.prototype._getInputDevicePromise=function(){return this._inputDevicePromise},t.prototype._maybeStartPollingVolume=function(){var e=this;if(this.isVolumeSupported&&this.inputStream&&(this._updateVolumeSource(),!this._isPollingInputVolume&&this._inputVolumeAnalyser)){var t=new Uint8Array(this._inputVolumeAnalyser.frequencyBinCount);this._isPollingInputVolume=!0;var n=function(){if(e._isPollingInputVolume){if(e._inputVolumeAnalyser){e._inputVolumeAnalyser.getByteFrequencyData(t);var r=f.average(t);e.emit("inputVolume",r/255)}requestAnimationFrame(n)}};requestAnimationFrame(n)}},t.prototype._maybeStopPollingVolume=function(){!this.isVolumeSupported||!this._isPollingInputVolume||this.inputStream&&this.listenerCount("inputVolume")||(this._inputVolumeSource&&(this._inputVolumeSource.disconnect(),delete this._inputVolumeSource),this._isPollingInputVolume=!1)},t.prototype._openDefaultDeviceWithConstraints=function(e){var t=this;return this._log.info("Opening default device with constraints",e),this._getUserMedia(e).then(function(e){return t._log.info("Opened default device. Updating available devices."),t._updateAvailableDevices().catch(function(e){t._log.warn("Unable to updateAvailableDevices after gUM call",e)}),t._defaultInputDeviceStream=e,t._maybeCreateProcessedStream(e)})},t.prototype._stopDefaultInputDeviceStream=function(){this._defaultInputDeviceStream&&(this._log.info("stopping default device stream"),this._defaultInputDeviceStream.getTracks().forEach(function(e){return e.stop()}),this._defaultInputDeviceStream=null,this._destroyProcessedStream())},t.prototype._unbind=function(){var e;(null===(e=this._mediaDevices)||void 0===e?void 0:e.removeEventListener)&&this._mediaDevices.removeEventListener("devicechange",this._updateAvailableDevices)},t.prototype._updateUserOptions=function(e){"function"==typeof e.enumerateDevices&&(this._enumerateDevices=e.enumerateDevices),"function"==typeof e.getUserMedia&&(this._getUserMedia=e.getUserMedia)},t.prototype.addProcessor=function(e){if(this._log.debug(".addProcessor"),this._processor)throw new u.NotSupportedError("Adding multiple AudioProcessors is not supported at this time.");if("object"!=typeof e||null===e)throw new u.InvalidArgumentError("Missing AudioProcessor argument.");if("function"!=typeof e.createProcessedStream)throw new u.InvalidArgumentError("Missing createProcessedStream() method.");if("function"!=typeof e.destroyProcessedStream)throw new u.InvalidArgumentError("Missing destroyProcessedStream() method.");return this._processor=e,this._audioProcessorEventObserver.emit("add"),this._restartStreams()},t.prototype.disconnect=function(e){return this._log.debug(".disconnect",e),this._maybeEnableSound(c.default.SoundName.Disconnect,e)},t.prototype.incoming=function(e){return this._log.debug(".incoming",e),this._maybeEnableSound(c.default.SoundName.Incoming,e)},t.prototype.outgoing=function(e){return this._log.debug(".outgoing",e),this._maybeEnableSound(c.default.SoundName.Outgoing,e)},t.prototype.removeProcessor=function(e){if(this._log.debug(".removeProcessor"),"object"!=typeof e||null===e)throw new u.InvalidArgumentError("Missing AudioProcessor argument.");if(this._processor!==e)throw new u.InvalidArgumentError("Cannot remove an AudioProcessor that has not been previously added.");return this._destroyProcessedStream(),this._processor=null,this._audioProcessorEventObserver.emit("remove"),this._restartStreams()},t.prototype.setAudioConstraints=function(e){return this._log.debug(".setAudioConstraints",e),this._audioConstraints=Object.assign({},e),delete this._audioConstraints.deviceId,this.inputDevice?this._setInputDevice(this.inputDevice.deviceId,!0):Promise.resolve()},t.prototype.setInputDevice=function(e){return this._log.debug(".setInputDevice",e),this._setInputDevice(e,!1)},t.prototype.unsetAudioConstraints=function(){return this._log.debug(".unsetAudioConstraints"),this._audioConstraints=null,this.inputDevice?this._setInputDevice(this.inputDevice.deviceId,!0):Promise.resolve()},t.prototype.unsetInputDevice=function(){var e=this;return(this._log.debug(".unsetInputDevice",this.inputDevice),this.inputDevice)?(this._destroyProcessedStream(),this._onActiveInputChanged(null).then(function(){e._replaceStream(null),e._inputDevice=null,e._maybeStopPollingVolume()})):Promise.resolve()}
1,t.prototype._destroyProcessedStream=function(){if(this._processor&&this._processedStream){this._log.info("destroying processed stream");var e=this._processedStream;this._processedStream.getTracks().forEach(function(e){return e.stop()}),this._processedStream=null,this._processor.destroyProcessedStream(e),this._audioProcessorEventObserver.emit("destroy")}},t.prototype._getUnknownDeviceIndex=function(e){var t=e.deviceId,n=e.kind,r=this._unknownDeviceIndexes[n][t];return r||(r=Object.keys(this._unknownDeviceIndexes[n]).length+1,this._unknownDeviceIndexes[n][t]=r),r},t.prototype._initializeEnumeration=function(){var e=this;if(!this._mediaDevices||!this._enumerateDevices)throw new u.NotSupportedError("Enumeration is not supported");this._mediaDevices.addEventListener&&this._mediaDevices.addEventListener("devicechange",this._updateAvailableDevices),this._updateAvailableDevices().then(function(){e.isOutputSelectionSupported&&Promise.all([e.speakerDevices.set("default"),e.ringtoneDevices.set("default")]).catch(function(t){e._log.warn("Warning: Unable to set audio output devices. "+t)})})},t.prototype._maybeCreateProcessedStream=function(e){var t=this;return this._processor?(this._log.info("Creating processed stream"),this._processor.createProcessedStream(e).then(function(e){return t._processedStream=e,t._audioProcessorEventObserver.emit("create"),t._processedStream})):Promise.resolve(e)},t.prototype._maybeEnableSound=function(e,t){return void 0!==t&&(this._enabledSounds[e]=t),this._enabledSounds[e]},t.prototype._replaceStream=function(e){this._log.info("Replacing with new stream."),this._selectedInputDeviceStream&&(this._log.info("Old stream detected. Stopping tracks."),this._stopSelectedInputDeviceStream()),this._selectedInputDeviceStream=e},t.prototype._restartStreams=function(){if(this.inputDevice&&this._selectedInputDeviceStream)return this._log.info("Restarting selected input device"),this._setInputDevice(this.inputDevice.deviceId,!0);if(this._defaultInputDeviceStream){var e=this.availableInputDevices.get("default")||Array.from(this.availableInputDevices.values())[0];return this._log.info("Restarting default input device, now becoming selected."),this._setInputDevice(e.deviceId,!0)}return Promise.resolve()},t.prototype._setInputDevice=function(e,t){return o(this,void 0,void 0,function(){var n,r=this;return a(this,function(i){return n=function(){return o(r,void 0,void 0,function(){var n,r,i=this;return a(this,function(o){switch(o.label){case 0:return[4,this._beforeSetInputDevice()];case 1:if(o.sent(),"string"!=typeof e)return[2,Promise.reject(new u.InvalidArgumentError("Must specify the device to set"))];if(!(n=this.availableInputDevices.get(e)))return[2,Promise.reject(new u.InvalidArgumentError("Device not found: "+e))];if(this._log.info("Setting input device. ID: "+e),this._inputDevice&&this._inputDevice.deviceId===e&&this._selectedInputDeviceStream){if(!t)return[2,Promise.resolve()];this._log.info("Same track detected on setInputDevice, stopping old tracks."),this._stopSelectedInputDeviceStream()}return this._stopDefaultInputDeviceStream(),r={audio:Object.assign({deviceId:{exact:e}},this.audioConstraints)},this._log.info("setInputDevice: getting new tracks."),[2,this._getUserMedia(r).then(function(e){return i._destroyProcessedStream(),i._maybeCreateProcessedStream(e).then(function(t){return i._log.info("setInputDevice: invoking _onActiveInputChanged."),i._onActiveInputChanged(t).then(function(){i._replaceStream(e),i._inputDevice=n,i._maybeStartPollingVolume()})})})]}})})},[2,this._inputDevicePromise=n().finally(function(){r._inputDevicePromise=null})]})})},t.prototype._stopMicrophonePermissionListener=function(){var e;(null===(e=this._microphonePermissionStatus)||void 0===e?void 0:e.removeEventListener)&&this._microphonePermissionStatus.removeEventListener("change",this._onMicrophonePermissionStatusChanged)},t.prototype._stopSelectedInputDeviceStream=function(){this._selectedInputDeviceStream&&(this._log.info("Stopping selected device stream"),this._selectedInputDeviceStream.getTracks().forEach(function(e){return e.stop()}))},t.prototype._updateDevices=function(e,t,n){var r=this,i=e.map(function(e){return e.deviceId}),o=Array.from(t.values()).map(function(e){return e.deviceId}),a=[],s=f.difference(o,i);
1s.forEach(function(e){var r=t.get(e);r&&(t.delete(e),n(r)&&a.push(r))});var c=!1;if(e.forEach(function(e){var n=t.get(e.deviceId),i=r._wrapMediaDeviceInfo(e);n&&n.label===i.label||(t.set(e.deviceId,i),c=!0)}),c||s.length){var u="default",d=this.inputDevice&&this.inputDevice.deviceId===u,l=this._defaultInputDeviceStream&&this.availableInputDevices.get(u);(d||l)&&(this._log.warn("Calling getUserMedia after device change to ensure that the tracks of the active device (default) have not gone stale."),setTimeout(function(){r._setInputDevice(u,!0)},0)),this._log.debug("#deviceChange",a),this.emit("deviceChange",a)}},t.prototype._updateVolumeSource=function(){if(this.inputStream&&this._audioContext&&this._inputVolumeAnalyser){this._inputVolumeSource&&this._inputVolumeSource.disconnect();try{this._inputVolumeSource=this._audioContext.createMediaStreamSource(this.inputStream),this._inputVolumeSource.connect(this._inputVolumeAnalyser)}catch(e){this._log.warn("Unable to update volume source",e),delete this._inputVolumeSource}}},t.prototype._wrapMediaDeviceInfo=function(e){var t={deviceId:e.deviceId,groupId:e.groupId,kind:e.kind,label:e.label};if(!t.label){if("default"===t.deviceId)t.label="Default";else{var n=this._getUnknownDeviceIndex(e);t.label="Unknown "+h[t.kind]+" Device "+n}}return new p.default(t)},t}(s.EventEmitter);m||(m={}),t.default=m},13600:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};Object.defineProperty(t,"__esModule",{value:!0});var s=n(24231),c=function(e){function t(t,n,r){void 0===n&&(n={}),void 0===r&&(r={});var i=e.call(this)||this;return i._audioNode=null,i._loop=!1,i._pendingPlayDeferreds=[],i._sinkId="default",i._src="","string"!=typeof n&&(r=n),i._audioContext=t,i._audioElement=new(r.AudioFactory||Audio),i._bufferPromise=i._createPlayDeferred().promise,i._destination=i._audioContext.destination,i._gainNode=i._audioContext.createGain(),i._gainNode.connect(i._destination),i._XMLHttpRequest=r.XMLHttpRequestFactory||XMLHttpRequest,i.addEventListener("canplaythrough",function(){i._resolvePlayDeferreds()}),"string"==typeof n&&(i.src=n),i}return i(t,e),Object.defineProperty(t.prototype,"destination",{get:function(){return this._destination},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loop",{get:function(){return this._loop},set:function(e){var t=this;e||!this.loop||this.paused||this._audioNode.addEventListener("ended",function e(){t._audioNode.removeEventListener("ended",e),t.pause()}),this._loop=e}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"muted",{get:function(){return 0===this._gainNode.gain.value},set:function(e){this._gainNode.gain.value=e?0:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paused",{get:function(){return null===this._audioNode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"src",{get:function(){return this._src},set:function(e){this._load(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"srcObject",{get:function(){return this._audioElement.srcObject},set:function(e){this._audioElement.srcObject=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sinkId",{get:function(){return this._sinkId},enumerable:!1,configurable:!0}),t.prototype.load=function(){this._load(this._src)},t.prototype.pause=function(){this.paused||(this._audioElement.pause(),this._audioNode.stop(),this._audioNode.disconnect(this._gainNode),this._audioNode=null,this._rejectPlayDeferreds(Error("The play() request was interrupted by a call to pause().")))},t.prototype.play=function(){return o(this,void 0,void 0,function(){var e,t=this;return a(this,function(n){switch(n.label){case 0:if(this.paused)return[3,2];return[4,this._bufferPromise];case 1:if(n.sent(),!this.paused)return[2];throw Error("The play() request was interrupted by a call to pause().");case 2:return this._audioNode=this._audioContext.createBufferSource(),this._audioNode.loop=this.loop,this._audioNode.addEventListener("ended",function(){t._audioNode&&t._audioNode.loop||t.dispatchEvent("ended")}),[4,this._bufferPromise];case 3:if(e=n.sent(),this.paused)throw Error("The play() request was interrupted by a call to pause().");if(this._audioNode.buffer=e,this._audioNode.connect(this._gainNode),this._audioNode.start(),this._audioElement.srcObject)return[2,this._audioElement.play()];return[2]}})})},t.prototype.setSinkId=function(e){return o(this,void 0,void 0,function(){return a(this,function(t){switch(t.label){case 0:if("function"!=typeof this._audioElement.setSinkId)throw Error("This browser does not support setSinkId.");if(e===this.sinkId)return[2];if("default"===e)return this.paused||this._gainNode.disconnect(this._destination),this._audioElement.srcObject=null,this._destination=this._audioContext.destination,this._gainNode.connect(this._destination),this._sinkId=e,[2];return[4,this._audioElement.setSinkId(e)];case 1:if(t.sent(),this._audioElement.srcObject)return[2];return this._gainNode.disconnect(this._audioContext.destination),this._destination=this._audioContext.createMediaStreamDestination(),this._audioElement.srcObject=this._destination.stream,this._sinkId=e,this._gainNode.connect(this._destination),[2]}})})},t.prototype._createPlayDeferred=function(){var e=new s.default;return this._pendingPlayDeferreds.push(e),e},t.prototype._load=function(e){var t=this;this._src&&this._src!==e&&this.pause(),this._src=e,this._bufferPromise=new Promise(function(n,r){return o(t,void 0,void 0,function(){var t;return a(this,function(r){switch(r.label){case 0:if(!e)return[2,this._createPlayDeferred().promise];return[4,function(e,t,n){return o(this,void 0,void 0,function(){var r,i;return a(this,function(o){switch(o.label){case 0:return(r=new t).open("GET",n,!0),r.responseType="arraybuffer",[4,new Promise(function(e){r.addEventListener("load",e),r.send()})];case 1:i=o.sent();try{return[2,e.decodeAudioData(i.target.response)]}catch(t){return[2,new Promise(function(t){e.decodeAudioData(i.target.response,t)})]}return[2]}})})}(this._audioContext,this._XMLHttpRequest,e)];case 1:return t=r.sent(),this.dispatchEvent("canplaythrough"),n(t),[2]}})})})},t.prototype._rejectPlayDeferreds=function(e){var t=this._pendingPlayDeferreds;t.splice(0,t.length).forEach(function(t){return(0,t.reject)(e)})},t.prototype._resolvePlayDeferreds=function(e){var t=this._pendingPlayDeferreds;t.splice(0,t.length).forEach(function(t){return(0,t.resolve)(e)})},t}(n(31078).default);t.default=c},24231:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){var e=this;this.promise=new Promise(function(t,n){e._resolve=t,e._reject=n})}return Object.defineProperty(e.prototype,"reject",{get:function(){return this._reject}
1,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"resolve",{get:function(){return this._resolve},enumerable:!1,configurable:!0}),e}();t.default=n},31078:function(e,t,n){"use strict";var r=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r};Object.defineProperty(t,"__esModule",{value:!0});var i=n(55445),o=function(){function e(){this._eventEmitter=new i.EventEmitter}return e.prototype.addEventListener=function(e,t){return this._eventEmitter.addListener(e,t)},e.prototype.dispatchEvent=function(e){for(var t,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return(t=this._eventEmitter).emit.apply(t,r([e],n))},e.prototype.removeEventListener=function(e,t){return this._eventEmitter.removeListener(e,t)},e}();t.default=o},48087:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.AudioProcessorEventObserver=void 0;var o=n(55445),a=n(92764),s=function(e){function t(){var t=e.call(this)||this;return t._log=new a.default("AudioProcessorEventObserver"),t._log.info("Creating AudioProcessorEventObserver instance"),t.on("enabled",function(){return t._reEmitEvent("enabled")}),t.on("add",function(){return t._reEmitEvent("add")}),t.on("remove",function(){return t._reEmitEvent("remove")}),t.on("create",function(){return t._reEmitEvent("create-processed-stream")}),t.on("destroy",function(){return t._reEmitEvent("destroy-processed-stream")}),t}return i(t,e),t.prototype.destroy=function(){this.removeAllListeners()},t.prototype._reEmitEvent=function(e){this._log.info("AudioProcessor:"+e),this.emit("event",{name:e,group:"audio-processor"})},t}(o.EventEmitter);t.AudioProcessorEventObserver=s},87921:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var n=e.call(this)||this;return Object.defineProperties(n,{_attempts:{value:0,writable:!0},_duration:{enumerable:!1,get:function(){var e=this._min*Math.pow(this._factor,this._attempts);if(this._jitter){var t=Math.random(),n=Math.floor(t*this._jitter*e);e=(1&Math.floor(10*t))==0?e-n:e+n}return 0|Math.min(e,this._max)}},_factor:{value:t.factor||2},_jitter:{value:t.jitter>0&&t.jitter<=1?t.jitter:0},_max:{value:t.max||1e4},_min:{value:t.min||100},_timeoutID:{value:null,writable:!0}}),n}return i(t,e),t.prototype.backoff=function(){var e=this,t=this._duration;this._timeoutID&&(clearTimeout(this._timeoutID),this._timeoutID=null),this.emit("backoff",this._attempts,t),this._timeoutID=setTimeout(function(){e.emit("ready",e._attempts,t),e._attempts++},t)},t.prototype.reset=function(){this._attempts=0,this._timeoutID&&(clearTimeout(this._timeoutID),this._timeoutID=null)},t}(n(55445).EventEmitter);t.default=o},22534:function(e,t,n){"use strict";var r,i,o,a,s,c,u,d,l,p=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),f=this&&this.__assign||function(){return(f=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};
1Object.defineProperty(t,"__esModule",{value:!0});var h=n(55445),m=n(87921),g=n(65718),v=n(12861),_=n(92764),y=n(88754),b=n(64597),S=n(72779),w=n(74455),E=n(41262),C=n(89157),P=n(6501),T={factor:1.1,jitter:.5,max:3e4,min:1},I={disconnect:!0,info:{code:31003,message:"Connection with Twilio was interrupted.",twilioError:new v.MediaErrors.ConnectionError}},k={packetsLostFraction:{max:"packet-loss",maxAverage:"packets-lost-fraction"}},x={audioInputLevel:"audio-input-level",audioOutputLevel:"audio-output-level",bytesReceived:"bytes-received",bytesSent:"bytes-sent",jitter:"jitter",mos:"mos",rtt:"rtt"},R={max:"high-",maxAverage:"high-",maxDuration:"constant-",min:"low-",minStandardDeviation:"constant-"},O=function(e){function t(n,r){var i=e.call(this)||this;i.parameters={},i._inputVolumeStreak=0,i._isAnswered=!1,i._isCancelled=!1,i._isRejected=!1,i._latestInputVolume=0,i._latestOutputVolume=0,i._log=new _.default("Call"),i._mediaStatus=t.State.Pending,i._messages=new Map,i._metricsSamples=[],i._options={MediaHandler:y.PeerConnection,enableImprovedSignalingErrorPrecision:!1,offerSdp:null,shouldPlayDisconnect:function(){return!0},voiceEventSidGenerator:C.generateVoiceEventSid},i._outputVolumeStreak=0,i._shouldSendHangup=!0,i._signalingStatus=t.State.Pending,i._soundcache=new Map,i._status=t.State.Pending,i._wasConnected=!1,i.toString=function(){return"[Twilio.Call instance]"},i._emitWarning=function(e,t,n,r,o,a){if(!("constant-audio-input-level"===t&&i.isMuted())){var s=o?"info":"warning";"constant-audio-output-level"===t&&(s="info");var c={threshold:n};if(r&&(r instanceof Array?c.values=r.map(function(e){return"number"==typeof e?Math.round(100*e)/100:r}):c.value=r),i._publisher.post(s,e+"warning"+(o?"-cleared":"-raised"),t,{data:c},i),"constant-audio-output-level"!==t){var u=o?"warning-cleared":"warning";i._log.debug("#"+u,t),i.emit(u,t,a&&!o?a:null)}}},i._onAck=function(e){var t=e.acktype,n=e.callsid,r=e.voiceeventsid;
1if(i.parameters.CallSid!==n){i._log.warn("Received ack from a different callsid: "+n);return}"message"===t&&i._onMessageSent(r)},i._onAnswer=function(e){"string"==typeof e.reconnect&&(i._signalingReconnectToken=e.reconnect),i._isAnswered&&i._status!==t.State.Reconnecting||(i._setCallSid(e),i._isAnswered=!0,i._maybeTransitionToOpen())},i._onCancel=function(e){var n=e.callsid;i.parameters.CallSid===n&&(i._isCancelled=!0,i._publisher.info("connection","cancel",null,i),i._cleanupEventListeners(),i._mediaHandler.close(),i._status=t.State.Closed,i._log.debug("#cancel"),i.emit("cancel"),i._pstream.removeListener("cancel",i._onCancel))},i._onConnected=function(){i._log.info("Received connected from pstream"),i._signalingReconnectToken&&i._mediaHandler.version&&i._pstream.reconnect(i._mediaHandler.version.getSDP(),i.parameters.CallSid,i._signalingReconnectToken)},i._onHangup=function(e){if(i.status()!==t.State.Closed){if(e.callsid&&(i.parameters.CallSid||i.outboundConnectionId)){if(e.callsid!==i.parameters.CallSid&&e.callsid!==i.outboundConnectionId)return}else if(e.callsid)return;if(i._log.info("Received HANGUP from gateway"),e.error){var n=e.error.code,r=v.getPreciseSignalingErrorByCode(i._options.enableImprovedSignalingErrorPrecision,n),o=void 0!==r?new r(e.error.message):new v.GeneralErrors.ConnectionError("Error sent from gateway in HANGUP",e.error);i._log.error("Received an error from the gateway:",o),i._log.debug("#error",o),i.emit("error",o)}i._shouldSendHangup=!1,i._publisher.info("connection","disconnected-by-remote",null,i),i._disconnect(null,!0),i._cleanupEventListeners()}},i._onMediaFailure=function(e){var n=t.MediaFailure,r=n.ConnectionDisconnected,o=n.ConnectionFailed,a=n.IceGatheringFailed,s=n.LowBytes,c=e===o||e===a;if(!E.isChrome(window,window.navigator)&&e===o)return i._mediaHandler.onerror(I);if(i._mediaStatus===t.State.Reconnecting){if(c){if(Date.now()-i._mediaReconnectStartTime>T.max)return i._log.warn("Exceeded max ICE retries"),i._mediaHandler.onerror(I);try{i._mediaReconnectBackoff.backoff()}catch(e){if(!(e.message&&"Backoff in progress."===e.message))throw e}}return}var u=i._mediaHandler.version.pc,d=u&&"disconnected"===u.iceConnectionState,l=i._monitor.hasActiveWarning("bytesSent","min")||i._monitor.hasActiveWarning("bytesReceived","min");if(e===s&&d||e===r&&l||c){var p=new v.MediaErrors.ConnectionError("Media connection failed.");i._log.warn("ICE Connection disconnected."),i._publisher.warn("connection","error",p,i),i._publisher.info("connection","reconnecting",null,i),i._mediaReconnectStartTime=Date.now(),i._status=t.State.Reconnecting,i._mediaStatus=t.State.Reconnecting,i._mediaReconnectBackoff.reset(),i._mediaReconnectBackoff.backoff(),i._log.debug("#reconnecting"),i.emit("reconnecting",p)}},i._onMediaReconnected=function(){i._mediaStatus===t.State.Reconnecting&&(i._log.info("ICE Connection reestablished."),i._mediaStatus=t.State.Open,i._signalingStatus===t.State.Open&&(i._publisher.info("connection","reconnected",null,i),i._log.debug("#reconnected"),i.emit("reconnected"),i._status=t.State.Open))},i._onMessageReceived=function(e){var t=e.callsid,n=e.content,r=e.contenttype,o=e.messagetype,a=e.voiceeventsid;if(i.parameters.CallSid!==t){i._log.warn("Received a message from a different callsid: "+t);return}var s={content:n,contentType:r,messageType:o,voiceEventSid:a};i._publisher.info("call-message",o,{content_type:r,event_type:"received",voice_event_sid:a},i),i._log.debug("#messageReceived",JSON.stringify(s)),i.emit("messageReceived",s)},i._onMessageSent=function(e){if(!i._messages.has(e)){i._log.warn("Received a messageSent with a voiceEventSid that doesn't exists: "+e);return}var t=i._messages.get(e);i._messages.delete(e),i._publisher.info("call-message",null==t?void 0:t.messageType,{content_type:null==t?void 0:t.contentType,event_type:"sent",voice_event_sid:e},i),i._log.debug("#messageSent",JSON.stringify(t)),i.emit("messageSent",t)},i._onRinging=function(e){if(i._setCallSid(e),i._status===t.State.Connecting||i._status===t.State.Ringing){var n=!!e.sdp;i._status=t.State.Ringing,i._publisher.info("connection","outgoing-ringing",{hasEarlyMedia:n},i),i._log.debug("#ringing"),i.emit("ringing",n)}},i._onRTCSample=function(e){var t=f(f({},e),{inputVolume:i._latestInputVolume,outputVolume:i._latestOutputVolume});i._codec=t.codecName,i._metricsSamples.push(t),i._metricsSamples.length>=10&&i._publishMetrics(),i.emit("sample",e)},i._onSignalingError=function(e){var t=e.callsid,n=e.voiceeventsid,r=e.error;if(i.parameters.CallSid!==t){i._log.warn("Received an error from a different callsid: "+t);return}if(n&&i._messages.has(n)){i._messages.delete(n),i._log.warn("Received an error while sending a message.",e),i._publisher.error("call-message","error",{code:r.code,message:r.message,voice_event_sid:n},i);var o=void 0,a=v.getPreciseSignalingErrorByCode(!!i._options.enableImprovedSignalingErrorPrecision,r.code);void 0!==a&&(o=new a(r)),o||(i._log.error("Unknown Call Message Error: ",r),o=new v.GeneralErrors.UnknownError(r.message,r)),i._log.debug("#error",r,o),i.emit("error",o)}},i._onSignalingReconnected=function(){i._signalingStatus===t.State.Reconnecting&&(i._log.info("Signaling Connection reestablished."),i._signalingStatus=t.State.Open,i._mediaStatus===t.State.Open&&(i._publisher.info("connection","reconnected",null,i),i._log.debug("#reconnected"),i.emit("reconnected"),i._status=t.State.Open))},i._onTransportClose=function(){i._log.error("Received transportClose from pstream"),i._log.debug("#transportClose"),i.emit("transportClose"),i._signalingReconnectToken?(i._status=t.State.Reconnecting,i._signalingStatus=t.State.Reconnecting,i._log.debug("#reconnecting"),i.emit("reconnecting",new v.SignalingErrors.ConnectionDisconnected)):(i._status=t.State.Closed,i._signalingStatus=t.State.Closed)},i._reemitWarning=function(e,t){var n,r=/^audio/.test(e.name)?"audio-level-":"network-quality-",o=R[e.threshold.name];e.name in k?n=k[e.name][e.threshold.name]:e.name in x&&(n=x[e.name]);var a=o+n;i._emitWarning(r,a,e.threshold.value,e.values||e.value,t,e)},i._reemitWarningCleared=function(e){i._reemitWarning(e,!0)},i._isUnifiedPlanDefault=n.isUnifiedPlanDefault,i._soundcache=n.soundcache,"function"==typeof n.onIgnore&&(i._onIgnore=n.onIgnore);
1var o=r&&r.twimlParams||{};i.customParameters=new Map(Object.entries(o).map(function(e){return[e[0],String(e[1])]})),Object.assign(i._options,r),i._options.callParameters&&(i.parameters=i._options.callParameters),i._options.reconnectToken&&(i._signalingReconnectToken=i._options.reconnectToken),i._voiceEventSidGenerator=i._options.voiceEventSidGenerator||C.generateVoiceEventSid,i._direction=i.parameters.CallSid&&!i._options.reconnectCallSid?t.CallDirection.Incoming:t.CallDirection.Outgoing,i.parameters?i.callerInfo=i.parameters.StirStatus?{isVerified:"TN-Validation-Passed-A"===i.parameters.StirStatus}:null:i.callerInfo=null,i._mediaReconnectBackoff=new m.default(T),i._mediaReconnectBackoff.on("ready",function(){return i._mediaHandler.iceRestart()}),i.outboundConnectionId="TJSxxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});var a=i._publisher=n.publisher;i._direction===t.CallDirection.Incoming?a.info("connection","incoming",null,i):a.info("connection","outgoing",{preflight:i._options.preflight,reconnect:!!i._options.reconnectCallSid},i);var s=i._monitor=new(i._options.StatsMonitor||w.default);return s.on("sample",i._onRTCSample),s.disableWarnings(),setTimeout(function(){return s.enableWarnings()},5e3),s.on("warning",function(e,n){("bytesSent"===e.name||"bytesReceived"===e.name)&&i._onMediaFailure(t.MediaFailure.LowBytes),i._reemitWarning(e,n)}),s.on("warning-cleared",function(e){i._reemitWarningCleared(e)}),i._mediaHandler=new i._options.MediaHandler(n.audioHelper,n.pstream,{RTCPeerConnection:i._options.RTCPeerConnection,codecPreferences:i._options.codecPreferences,dscp:i._options.dscp,forceAggressiveIceNomination:i._options.forceAggressiveIceNomination,isUnifiedPlan:i._isUnifiedPlanDefault,maxAverageBitrate:i._options.maxAverageBitrate}),i.on("volume",function(e,t){i._inputVolumeStreak=i._checkVolume(e,i._inputVolumeStreak,i._latestInputVolume,"input"),i._outputVolumeStreak=i._checkVolume(t,i._outputVolumeStreak,i._latestOutputVolume,"output"),i._latestInputVolume=e,i._latestOutputVolume=t}),i._mediaHandler.onaudio=function(e){i._log.debug("#audio"),i.emit("audio",e)},i._mediaHandler.onvolume=function(e,t,n,r){s.addVolumes(n/255*32767,r/255*32767),i.emit("volume",e,t)},i._mediaHandler.ondtlstransportstatechange=function(e){i._publisher.post("failed"===e?"error":"debug","dtls-transport-state",e,null,i)},i._mediaHandler.onpcconnectionstatechange=function(e){var t="debug",n=i._mediaHandler.getRTCDtlsTransport();"failed"===e&&(t=n&&"failed"===n.state?"error":"warning"),i._publisher.post(t,"pc-connection-state",e,null,i)},i._mediaHandler.onicecandidate=function(e){var t=new b.IceCandidate(e).toPayload();i._publisher.debug("ice-candidate","ice-candidate",t,i)},i._mediaHandler.onselectedcandidatepairchange=function(e){var t=new b.IceCandidate(e.local).toPayload(),n=new b.IceCandidate(e.remote,!0).toPayload();i._publisher.debug("ice-candidate","selected-ice-candidate-pair",{local_candidate:t,remote_candidate:n},i)},i._mediaHandler.oniceconnectionstatechange=function(e){i._publisher.post("failed"===e?"error":"debug","ice-connection-state",e,null,i)},i._mediaHandler.onicegatheringfailure=function(e){i._publisher.warn("ice-gathering-state",e,null,i),i._onMediaFailure(t.MediaFailure.IceGatheringFailed)},i._mediaHandler.onicegatheringstatechange=function(e){i._publisher.debug("ice-gathering-state",e,null,i)},i._mediaHandler.onsignalingstatechange=function(e){i._publisher.debug("signaling-state",e,null,i)},i._mediaHandler.ondisconnected=function(e){i._log.warn(e),i._publisher.warn("network-quality-warning-raised","ice-connectivity-lost",{message:e},i),i._log.debug("#warning","ice-connectivity-lost"),i.emit("warning","ice-connectivity-lost"),i._onMediaFailure(t.MediaFailure.ConnectionDisconnected)},i._mediaHandler.onfailed=function(e){i._onMediaFailure(t.MediaFailure.ConnectionFailed)},i._mediaHandler.onconnected=function(){i._status===t.State.Reconnecting&&i._onMediaReconnected()},i._mediaHandler.onreconnected=function(e){i._log.info(e),i._publisher.info("network-quality-warning-cleared","ice-connectivity-lost",{message:e},i),i._log.debug("#warning-cleared","ice-connectivity-lost"),i.emit("warning-cleared","ice-connectivity-lost"),i._onMediaReconnected()},i._mediaHandler.onerror=function(e){!0===e.disconnect&&i._disconnect(e.info&&e.info.message);var t=e.info.twilioError||new v.GeneralErrors.UnknownError(e.info.message);i._log.error("Received an error from MediaStream:",e),i._log.debug("#error",t),i.emit("error",t)},i._mediaHandler.onopen=function(){i._status!==t.State.Open&&i._status!==t.State.Reconnecting&&(i._status===t.State.Ringing||i._status===t.State.Connecting?(i.mute(i._mediaHandler.isMuted),i._mediaStatus=t.State.Open,i._maybeTransitionToOpen()):i._mediaHandler.close())},i._mediaHandler.onclose=function(){i._status=t.State.Closed,i._options.shouldPlayDisconnect&&i._options.shouldPlayDisconnect()&&!i._isCancelled&&!i._isRejected&&i._soundcache.get(g.default.SoundName.Disconnect).play(),s.disable(),i._publishMetrics(),i._isCancelled||i._isRejected||(i._log.debug("#disconnect"),i.emit("disconnect",i))},i._pstream=n.pstream,i._pstream.on("ack",i._onAck),i._pstream.on("cancel",i._onCancel),i._pstream.on("error",i._onSignalingError),i._pstream.on("ringing",i._onRinging),i._pstream.on("transportClose",i._onTransportClose),i._pstream.on("connected",i._onConnected),i._pstream.on("message",i._onMessageReceived),i.on("error",function(e){i._publisher.error("connection","error",{code:e.code,message:e.message},i),i._pstream&&"disconnected"===i._pstream.status&&i._cleanupEventListeners()}),i.on("disconnect",function(){i._cleanupEventListeners()}),i}return p(t,e),Object.defineProperty(t.prototype,"direction",{get:function(){return this._direction}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"codec",{get:function(){return this._codec},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connectToken",{get:function(){var e=this,t=this._signalingReconnectToken,n=this.parameters&&this.parameters.CallSid?this.parameters.CallSid:void 0;if(t&&n)return btoa(encodeURIComponent(JSON.stringify({customParameters:this.customParameters&&"function"==typeof this.customParameters.keys?Array.from(this.customParameters.keys()).reduce(function(t,n){return t[n]=e.customParameters.get(n),t},{}):{},parameters:this.parameters||{},signalingReconnectToken:t})))},enumerable:!1,configurable:!0}),t.prototype._setInputTracksFromStream=function(e){return this._mediaHandler.setInputTracksFromStream(e)},t.prototype._setSinkIds=function(e){return this._mediaHandler._setSinkIds(e)},t.prototype.accept=function(e){var n=this;if(this._log.debug(".accept",e),this._status!==t.State.Pending){this._log.debug(".accept noop. status is '"+this._status+"'");return}var r=(e=e||{}).rtcConfiguration||this._options.rtcConfiguration,i=e.rtcConstraints||this._options.rtcConstraints||{},o={audio:void 0===i.audio||i.audio};this._status=t.State.Connecting;var a=function(){if(n._status!==t.State.Connecting){n._cleanupEventListeners(),n._mediaHandler.close();return}var e=function(e){var r=n._direction===t.CallDirection.Incoming?"accepted-by-local":"accepted-by-remote";n._publisher.info("connection",r,null,n);var i=S.getPreferredCodecInfo(n._mediaHandler.version.getSDP()),o=i.codecName,a=i.codecParams;n._publisher.info("settings","codec",{codec_params:a,selected_codec:o},n),n._monitor.enable(e)},i="function"==typeof n._options.getSinkIds&&n._options.getSinkIds();if(Array.isArray(i)&&n._mediaHandler._setSinkIds(i).catch(function(){}),n._pstream.addListener("hangup",n._onHangup),n._direction===t.CallDirection.Incoming)n._isAnswered=!0,n._pstream.on("answer",n._onAnswer),n._mediaHandler.answerIncomingCall(n.parameters.CallSid,n._options.offerSdp,r,e);else{var o=Array.from(n.customParameters.entries()).map(function(e){return encodeURIComponent(e[0])+"="+encodeURIComponent(e[1])}).join("&");n._pstream.on("answer",n._onAnswer),n._mediaHandler.makeOutgoingCall(o,n._signalingReconnectToken,n._options.reconnectCallSid||n.outboundConnectionId,r,e)}};this._options.beforeAccept&&this._options.beforeAccept(this);var s="function"==typeof this._options.getInputStream&&this._options.getInputStream();(s?this._mediaHandler.setInputTracksFromStream(s):this._mediaHandler.openDefaultDeviceWithConstraints(o)).then(function(){n._publisher.info("get-user-media","succeeded",{data:{audioConstraints:o}},n),a()},function(e){var t;31208===e.code||-1!==["PermissionDeniedError","NotAllowedError"].indexOf(e.name)?(t=new v.UserMediaErrors.PermissionDeniedError,n._publisher.error("get-user-media","denied",{data:{audioConstraints:o,error:e}},n)):(t=new v.UserMediaErrors.AcquisitionFailedError,n._publisher.error("get-user-media","failed",{data:{audioConstraints:o,error:e}},n)),n._disconnect(),n._log.debug("#error",e),n.emit("error",t)})},t.prototype.disconnect=function(){this._log.debug(".disconnect"),this._disconnect()},t.prototype.getLocalStream=function(){return this._mediaHandler&&this._mediaHandler.stream},t.prototype.getRemoteStream=function(){return this._mediaHandler&&this._mediaHandler._remoteStream},t.prototype.ignore=function(){if(this._log.debug(".ignore"),this._status!==t.State.Pending){this._log.debug(".ignore noop. status is '"+this._status+"'");return}this._status=t.State.Closed,this._mediaHandler.ignore(this.parameters.CallSid),this._publisher.info("connection","ignored-by-local",null,this),this._onIgnore&&this._onIgnore()},t.prototype.isMuted=function(){return this._mediaHandler.isMuted},t.prototype.mute=function(e){void 0===e&&(e=!0),this._log.debug(".mute",e);var t=this._mediaHandler.isMuted;this._mediaHandler.mute(e);var n=this._mediaHandler.isMuted;t!==n&&(this._publisher.info("connection",n?"muted":"unmuted",null,this),this._log.debug("#mute",n),this.emit("mute",n,this))},t.prototype.postFeedback=function(e,n){if(null==e)return this._postFeedbackDeclined();if(!Object.values(t.FeedbackScore).includes(e))throw new v.InvalidArgumentError("Feedback score must be one of: "+Object.values(t.FeedbackScore));if(null!=n&&!Object.values(t.FeedbackIssue).includes(n))throw new v.InvalidArgumentError("Feedback issue must be one of: "+Object.values(t.FeedbackIssue));return this._publisher.info("feedback","received",{issue_name:n,quality_score:e},this,!0)},t.prototype.reject=function(){if(this._log.debug(".reject"),this._status!==t.State.Pending){this._log.debug(".reject noop. status is '"+this._status+"'");return}this._isRejected=!0,this._pstream.reject(this.parameters.CallSid),this._mediaHandler.reject(this.parameters.CallSid),this._publisher.info("connection","rejected-by-local",null,this),this._cleanupEventListeners(),this._mediaHandler.close(),this._status=t.State.Closed,this._log.debug("#reject"),this.emit
1("reject")},t.prototype.sendDigits=function(e){var t=this;if(this._log.debug(".sendDigits",e),e.match(/[^0-9*#w]/))throw new v.InvalidArgumentError("Illegal character passed into sendDigits");var n=this._options.customSounds||{},r=[];e.split("").forEach(function(e){var t="w"!==e?"dtmf"+e:"";"dtmf*"===t&&(t="dtmfs"),"dtmf#"===t&&(t="dtmfh"),r.push(t)});var i=function(){var e=r.shift();e&&(t._options.dialtonePlayer&&!n[e]?t._options.dialtonePlayer.play(e):t._soundcache.get(e).play()),r.length&&setTimeout(function(){return i()},200)};i();var o=this._mediaHandler.getOrCreateDTMFSender();if(o){if(!("canInsertDTMF"in o)||o.canInsertDTMF){this._log.info("Sending digits using RTCDTMFSender"),function e(t){if(t.length){var n=t.shift();n&&n.length&&o.insertDTMF(n,160,70),setTimeout(e.bind(null,t),500)}}(e.split("w"));return}this._log.info("RTCDTMFSender cannot insert DTMF")}if(this._log.info("Sending digits over PStream"),null!==this._pstream&&"disconnected"!==this._pstream.status)this._pstream.dtmf(this.parameters.CallSid,e);else{var a=new v.GeneralErrors.ConnectionError("Could not send DTMF: Signaling channel is disconnected");this._log.debug("#error",a),this.emit("error",a)}},t.prototype.sendMessage=function(e){this._log.debug(".sendMessage",JSON.stringify(e));var t=e.content,n=e.contentType,r=e.messageType;if(null==t)throw new v.InvalidArgumentError("`content` is empty");if("string"!=typeof r)throw new v.InvalidArgumentError("`messageType` must be a string.");if(0===r.length)throw new v.InvalidArgumentError("`messageType` must be a non-empty string.");if(null===this._pstream)throw new v.InvalidStateError("Could not send CallMessage; Signaling channel is disconnected");var i=this.parameters.CallSid;if(void 0===this.parameters.CallSid)throw new v.InvalidStateError("Could not send CallMessage; Call has no CallSid");var o=this._voiceEventSidGenerator();return this._messages.set(o,{content:t,contentType:n,messageType:r,voiceEventSid:o}),this._pstream.sendMessage(i,t,n,r,o),o},t.prototype.status=function(){return this._status},t.prototype._checkVolume=function(e,t,n,r){var i=0;return n===e&&(i=t),i>=10?this._emitWarning("audio-level-","constant-audio-"+r+"-level",10,i,!1):t>=10&&this._emitWarning("audio-level-","constant-audio-"+r+"-level",10,i,!0),i},t.prototype._cleanupEventListeners=function(){var e=this,t=function(){e._pstream&&(e._pstream.removeListener("ack",e._onAck),e._pstream.removeListener("answer",e._onAnswer),e._pstream.removeListener("cancel",e._onCancel),e._pstream.removeListener("error",e._onSignalingError),e._pstream.removeListener("hangup",e._onHangup),e._pstream.removeListener("ringing",e._onRinging),e._pstream.removeListener("transportClose",e._onTransportClose),e._pstream.removeListener("connected",e._onConnected),e._pstream.removeListener("message",e._onMessageReceived))};t(),setTimeout(t,0)},t.prototype._createMetricPayload=function(){var e={call_sid:this.parameters.CallSid,dscp:!!this._options.dscp,sdk_version:P.RELEASE_VERSION};return this._options.gateway&&(e.gateway=this._options.gateway),e.direction=this._direction,e},t.prototype._disconnect=function(e,n){if(e="string"==typeof e?e:null,this._status===t.State.Open||this._status===t.State.Connecting||this._status===t.State.Reconnecting||this._status===t.State.Ringing){if(this._log.info("Disconnecting..."),null!==this._pstream&&"disconnected"!==this._pstream.status&&this._shouldSendHangup){var r=this.parameters.CallSid||this.outboundConnectionId;r&&this._pstream.hangup(r,e)}this._cleanupEventListeners(),this._mediaHandler.close(),n||this._publisher.info("connection","disconnected-by-local",null,this)}},t.prototype._maybeTransitionToOpen=function(){this._wasConnected,this._isAnswered&&(this._onSignalingReconnected(),this._signalingStatus=t.State.Open,this._mediaHandler&&"open"===this._mediaHandler.status&&(this._status=t.State.Open,this._wasConnected||(this._wasConnected=!0,this._log.debug("#accept"),this.emit("accept",this))))},t.prototype._postFeedbackDeclined=function(){return this._publisher.info("feedback","received-none",null,this,!0)},t.prototype._publishMetrics=function(){var e=this;0!==this._metricsSamples.length&&this._publisher.postMetrics("quality-metrics-samples","metrics-sample",this._metricsSamples.splice(0),this._createMetricPayload(),this).catch(function(t){e._log.warn("Unable to post metrics to Insights. Received error:",t)})},t.prototype._setCallSid=function(e){var t=e.callsid;t&&(this.parameters.CallSid=t,this._mediaHandler.callSid=t)},t.toString=function(){return"[Twilio.Call class]"},t}(h.EventEmitter);(o=(i=O||(O={})).State||(i.State={})).Closed="closed",o.Connecting="connecting",o.Open="open",o.Pending="pending",o.Reconnecting="reconnecting",o.Ringing="ringing",(a=i.FeedbackIssue||(i.FeedbackIssue={})).AudioLatency="audio-latency",a.ChoppyAudio="choppy-audio",a.DroppedCall="dropped-call",a.Echo="echo",a.NoisyCall="noisy-call",a.OneWayAudio="one-way-audio",(s=i.FeedbackScore||(i.FeedbackScore={}))[s.One=1]="One",s[s.Two=2]="Two",s[s.Three=3]="Three",s[s.Four=4]="Four",s[s.Five=5]="Five",(c=i.CallDirection||(i.CallDirection={})).Incoming="INCOMING",c.Outgoing="OUTGOING",(u=i.Codec||(i.Codec={})).Opus="opus",u.PCMU="pcmu",(d=i.IceGatheringFailureReason||(i.IceGatheringFailureReason={})).None="none",d.Timeout="timeout",(l=i.MediaFailure||(i.MediaFailure={})).ConnectionDisconnected="ConnectionDisconnected",l.ConnectionFailed="ConnectionFailed",l.IceGatheringFailed="IceGatheringFailed",l.LowBytes="LowBytes",t.default=O},6501:function(e,t){"use strict";
1Object.defineProperty(t,"__esModule",{value:!0}),t.SOUNDS_BASE_URL=t.RELEASE_VERSION=t.PACKAGE_NAME=t.ECHO_TEST_DURATION=t.COWBELL_AUDIO_URL=void 0,t.PACKAGE_NAME="@twilio/voice-sdk";var n="2.12.4";t.RELEASE_VERSION=n;var r="https://sdk.twilio.com/js/client/sounds/releases/1.0.0";t.SOUNDS_BASE_URL=r;var i=r+"/cowbell.mp3?cache="+n;t.COWBELL_AUDIO_URL=i,t.ECHO_TEST_DURATION=2e4},42721:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){var e=this;this._promise=new Promise(function(t,n){e._resolve=t,e._reject=n})}return Object.defineProperty(e.prototype,"promise",{get:function(){return this._promise},enumerable:!1,configurable:!0}),e.prototype.reject=function(e){this._reject(e)},e.prototype.resolve=function(e){this._resolve(e)},e}();t.default=n},65718:function(e,t,n){"use strict";var r,i,o,a,s,c=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),u=this&&this.__assign||function(){return(u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},d=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},l=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};Object.defineProperty(t,"__esModule",{value:!0});var p=n(55445),f=n(86005),h=n(20407),m=n(48087),g=n(22534),v=n(6501),_=n(39324),y=n(12861),b=n(30821),S=n(92764),w=n(7562),E=n(47397),C=n(29767),P=n(88754),T=n(27491),I=n(50070),k=n(41262),x=n(89157),R=function(e){function t(n,r){void 0===r&&(r={});var i,o=e.call(this)||this;if(o._activeCall=null,o._audio=null,o._audioProcessorEventObserver=null,o._callInputStream=null,o._calls=[],o._callSinkIds=["default"],o._chunderURIs=[],o._defaultOptions={allowIncomingWhileBusy:!1,closeProtection:!1,codecPreferences:[g.default.Codec.PCMU,g.default.Codec.Opus],dscp:!0,enableImprovedSignalingErrorPrecision:!1,forceAggressiveIceNomination:!1,logLevel:f.levels.ERROR,maxCallSignalingTimeoutMs:0,preflight:!1,sounds:{},tokenRefreshMs:1e4,voiceEventSidGenerator:x.generateVoiceEventSid},o._edge=null,o._home=null,o._identity=null,o._log=new S.default("Device"),o._makeCallPromise=null,o._options={},o._preferredURI=null,o._publisher=null,o._region=null,o._regTimer=null,o._shouldReRegister=!1,o._soundcache=new Map,o._state=t.State.Unregistered,o._stateEventMapping=((i={})[t.State.Destroyed]=t.EventName.Destroyed,i[t.State.Unregistered]=t.EventName.Unregistered,i[t.State.Registering]=t.EventName.Registering,i[t.State.Registered]=t.EventName.Registered,i),o._stream=null,o._streamConnectedPromise=null,o._tokenWillExpireTimeout=null,o._createDefaultPayload=function(e){var t={aggressive_nomination:o._options.forceAggressiveIceNomination,browser_extension:o._isBrowserExtension,dscp:!!o._options.dscp,ice_restart_enabled:!0,platform:P.getMediaEngine(),sdk_version:v.RELEASE_VERSION};function n(e,n){n&&(t[e]=n)}if(e){var r=e.parameters.CallSid;n("call_sid",/^TJ/.test(r)?void 0:r),n("temp_call_sid",e.outboundConnectionId),n("audio_codec",e.codec),t.direction=e.direction}return n("gateway",o._stream&&o._stream.gateway),n("region",o._stream&&o._stream.region),t},o._onSignalingClose=function(){o._stream=null,o._streamConnectedPromise=null},o._onSignalingConnected=function(e){var t,n=C.getRegionShortcode(e.region);if(o._edge=e.edge||C.regionToEdge[n]||e.region,o._region=n||e.region,o._home=e.home,null===(t=o._publisher)||void 0===t||t.setHost(C.createEventGatewayURI(e.home)),e.token&&(o._identity=e.token.identity,"number"==typeof e.token.ttl&&"number"==typeof o._options.tokenRefreshMs)){var r=Math.max(0,1e3*e.token.ttl-o._options.tokenRefreshMs);o._tokenWillExpireTimeout=setTimeout(function(){o._log.debug("#tokenWillExpire"),o.emit("tokenWillExpire",o),o._tokenWillExpireTimeout&&(clearTimeout(o._tokenWillExpireTimeout),o._tokenWillExpireTimeout=null)},r)}var i=o._getChunderws()||C.getChunderURIs(o._edge);if(i.length>0){var a=i[0];o._preferredURI=C.createSignalingEndpointURL(a)}else o._log.warn("Could not parse a preferred URI from the stream#connected event.");o._shouldReRegister&&o.register()},o._onSignalingError=function(e){if("object"!=typeof e){o._log.warn("Invalid signaling error payload",e);return}var n=e.error,r=e.callsid,i=e.voiceeventsid;if("object"!=typeof n||i){o._log.warn("Ignoring signaling error payload",{originalError:n,voiceeventsid:i});return}var a="string"==typeof r&&o._findCall(r)||void 0,s=n.code,c=n.message,u=n.twilioError;if("number"==typeof s){if(31201===s)u=new y.AuthorizationErrors.AuthenticationFailed(n);else if(31204===s)u=new y.AuthorizationErrors.AccessTokenInvalid(n);else if(31205===s)o._stopRegistrationTimer(),u=new y.AuthorizationErrors.AccessTokenExpired(n);
1else{var d=y.getPreciseSignalingErrorByCode(!!o._options.enableImprovedSignalingErrorPrecision,s);void 0!==d&&(u=new d(n))}}u||(o._log.error("Unknown signaling error: ",n),u=new y.GeneralErrors.UnknownError(c,n)),o._log.error("Received error: ",u),o._log.debug("#error",n),o.emit(t.EventName.Error,u,a)},o._onSignalingInvite=function(e){return d(o,void 0,void 0,function(){var n,r,i,o,a,s,c=this;return l(this,function(u){switch(u.label){case 0:if((n=!!this._activeCall)&&!this._options.allowIncomingWhileBusy)return this._log.info("Device busy; ignoring incoming invite"),[2];if(!e.callsid||!e.sdp)return this._log.debug("#error",e),this.emit(t.EventName.Error,new y.ClientErrors.BadRequest("Malformed invite from gateway")),[2];(r=e.parameters||{}).CallSid=r.CallSid||e.callsid,i=Object.assign({},k.queryToJson(r.Params)),this._makeCallPromise=this._makeCall(i,{callParameters:r,enableImprovedSignalingErrorPrecision:!!this._options.enableImprovedSignalingErrorPrecision,offerSdp:e.sdp,reconnectToken:e.reconnect,voiceEventSidGenerator:this._options.voiceEventSidGenerator}),u.label=1;case 1:return u.trys.push([1,,3,4]),[4,this._makeCallPromise];case 2:return o=u.sent(),[3,4];case 3:return this._makeCallPromise=null,[7];case 4:return this._calls.push(o),o.once("accept",function(){c._soundcache.get(t.SoundName.Incoming).stop(),c._publishNetworkChange()}),a=(null===(s=this._audio)||void 0===s?void 0:s.incoming())&&!n?function(){return c._soundcache.get(t.SoundName.Incoming).play()}:function(){return Promise.resolve()},this._showIncomingCall(o,a),[2]}})})},o._onSignalingOffline=function(){o._log.info("Stream is offline"),o._edge=null,o._region=null,o._shouldReRegister=o.state!==t.State.Unregistered,o._setState(t.State.Unregistered)},o._onSignalingReady=function(){o._log.info("Stream is ready"),o._setState(t.State.Registered)},o._publishNetworkChange=function(){o._activeCall&&o._networkInformation&&o._publisher.info("network-information","network-change",{connection_type:o._networkInformation.type,downlink:o._networkInformation.downlink,downlinkMax:o._networkInformation.downlinkMax,effective_type:o._networkInformation.effectiveType,rtt:o._networkInformation.rtt},o._activeCall)},o._updateInputStream=function(e){var t=o._activeCall;return t&&!e?Promise.reject(new y.InvalidStateError("Cannot unset input device while a call is in progress.")):(o._callInputStream=e,t?t._setInputTracksFromStream(e):Promise.resolve())},o._updateSinkIds=function(e,t){return("ringtone"===e?o._updateRingtoneSinkIds(t):o._updateSpeakerSinkIds(t)).then(function(){o._publisher.info("audio",e+"-devices-set",{audio_device_ids:t},o._activeCall)},function(n){throw o._publisher.error("audio",e+"-devices-set-failed",{audio_device_ids:t,message:n.message},o._activeCall),n})},o._setupLoglevel(r.logLevel),o._logOptions("constructor",r),o.updateToken(n),k.isLegacyEdge())throw new y.NotSupportedError("Microsoft Edge Legacy (https://support.microsoft.com/en-us/help/4533505/what-is-microsoft-edge-legacy) is deprecated and will not be able to connect to Twilio to make or receive calls after September 1st, 2020. Please see this documentation for a list of supported browsers https://www.twilio.com/docs/voice/client/javascript#supported-browsers");if(!t.isSupported&&r.ignoreBrowserSupport){if(window&&window.location&&"http:"===window.location.protocol)throw new y.NotSupportedError("twilio.js wasn't able to find WebRTC browser support. This is most likely because this page is served over http rather than https, which does not support WebRTC in many browsers. Please load this page over https and try again.");throw new y.NotSupportedError("twilio.js 1.3+ SDKs require WebRTC browser support. For more information, see <https://www.twilio.com/docs/api/client/twilio-js>. If you have any questions about this announcement, please contact Twilio Support at <[email protected]>.")}var a=globalThis,s=a.msBrowser||a.browser||a.chrome;if(o._isBrowserExtension=!!s&&!!s.runtime&&!!s.runtime.id||!!a.safari&&!!a.safari.extension,o._isBrowserExtension&&o._log.info("Running as browser extension."),navigator){var c=navigator;o._networkInformation=c.connection||c.mozConnection||c.webkitConnection}return o._networkInformation&&"function"==typeof o._networkInformation.addEventListener&&o._networkInformation.addEventListener("change",o._publishNetworkChange),t._getOrCreateAudioContext(),t._audioContext&&!t._dialtonePlayer&&(t._dialtonePlayer=new _.default(t._audioContext)),void 0===t._isUnifiedPlanDefault&&(t._isUnifiedPlanDefault="undefined"!=typeof window&&"undefined"!=typeof RTCPeerConnection&&"undefined"!=typeof RTCRtpTransceiver&&k.isUnifiedPlanDefault(window,window.navigator,RTCPeerConnection,RTCRtpTransceiver)),o._boundDestroy=o.destroy.bind(o),o._boundConfirmClose=o._confirmClose.bind(o),"undefined"!=typeof window&&window.addEventListener&&(window.addEventListener("unload",o._boundDestroy),window.addEventListener("pagehide",o._boundDestroy)),o.updateOptions(r),o}return c(t,e),Object.defineProperty(t,"audioContext",{get:function(){return t._audioContext}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t,"extension",{get:function(){var e,t,n="undefined"!=typeof document?document.createElement("audio"):{canPlayType:!1};try{e=n.canPlayType&&!!n.canPlayType("audio/mpeg").replace(/no/,"")}catch(t){e=!1}try{t=n.canPlayType&&!!n.canPlayType("audio/ogg;codecs='vorbis'").replace(/no/,"")}catch(e){t=!1}return t&&!e?"ogg":"mp3"},enumerable:!1,configurable:!0}),Object.defineProperty(t,"isSupported",{get:function(){return P.enabled()},enumerable:!1,configurable:!0}),Object.defineProperty(t,"packageName",{get:function(){return v.PACKAGE_NAME},enumerable:!1,configurable:!0}),t.runPreflight=function(e,n){return new w.PreflightTest(e,u({audioContext:t._getOrCreateAudioContext()},n))},t.toString=function(){return"[Twilio.Device class]"},Object.defineProperty(t,"version",{get:function(){return v.RELEASE_VERSION},enumerable:!1,configurable:!0}),t._getOrCreateAudioContext=function(){return t._audioContext||("undefined"!=typeof AudioContext?t._audioContext=new AudioContext:"undefined"!=typeof webkitAudioContext&&(t._audioContext=new webkitAudioContext)),t._audioContext},Object.defineProperty(t.prototype,"audio",{get:function(){return this._audio},enumerable:!1,configurable:!0}),t.prototype.connect=function(e){return void 0===e&&(e={}),d(this,void 0,void 0,function(){var n,r,i,o,a,s,c,u,d;return l(this,function(l){switch(l.label){case 0:if(this._log.debug(".connect",JSON.stringify(e)),this._throwIfDestroyed(),this._activeCall)throw new y.InvalidStateError("A Call is already active");if(e.connectToken){try{n=(o=JSON.parse(decodeURIComponent(atob(e.connectToken)))).customParameters,r=o.parameters,i=o.signalingReconnectToken}catch(e){throw new y.InvalidArgumentError("Cannot parse connectToken")}if(!r||!r.CallSid||!i)throw new y.InvalidArgumentError("Invalid connectToken")}a=!1,s={},c={enableImprovedSignalingErrorPrecision:!!this._options.enableImprovedSignalingErrorPrecision,rtcConfiguration:e.rtcConfiguration,voiceEventSidGenerator:this._options.voiceEventSidGenerator},i&&r?(a=!0,c.callParameters=r,c.reconnectCallSid=r.CallSid,c.reconnectToken=i,s=n||s):s=e.params||s,this._makeCallPromise=this._makeCall(s,c,a),l.label=1;case 1:return l.trys.push([1,,3,4]),d=this,[4,this._makeCallPromise];case 2:return u=d._activeCall=l.sent(),[3,4];case 3:return this._makeCallPromise=null,[7];case 4:return this._calls.splice(0).forEach(function(e){return e.ignore()}),this._soundcache.get(t.SoundName.Incoming).stop(),u.accept({rtcConstraints:e.rtcConstraints}),this._publishNetworkChange(),[2,u]}})})},Object.defineProperty(t.prototype,"calls",{get:function(){return this._calls},enumerable:!1,configurable:!0}),t.prototype.destroy=function(){var e;this._log.debug(".destroy"),this._log.debug("Rejecting any incoming calls"),this._calls.slice(0).forEach(function(e){return e.reject()}),this.disconnectAll(),this._stopRegistrationTimer(),this._destroyStream(),this._destroyAudioHelper(),null===(e=this._audioProcessorEventObserver)||void 0===e||e.destroy(),this._destroyPublisher(),this._networkInformation&&"function"==typeof this._networkInformation.removeEventListener&&this._networkInformation.removeEventListener("change",this._publishNetworkChange),"undefined"!=typeof window&&window.removeEventListener&&(window.removeEventListener("beforeunload",this._boundConfirmClose),window.removeEventListener("unload",this._boundDestroy),window.removeEventListener("pagehide",this._boundDestroy)),this._setState(t.State.Destroyed),p.EventEmitter.prototype.removeAllListeners.call(this)},t.prototype.disconnectAll=function(){this._log.debug(".disconnectAll"),this._calls.splice(0).forEach(function(e){return e.disconnect()}),this._activeCall&&this._activeCall.disconnect()},Object.defineProperty(t.prototype,"edge",{get:function(){return this._edge},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"home",{get:function(){return this._home},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"identity",{get:function(){return this._identity},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBusy",{get:function(){return!!this._activeCall}
1,enumerable:!1,configurable:!0}),t.prototype.register=function(){return d(this,void 0,void 0,function(){return l(this,function(e){switch(e.label){case 0:if(this._log.debug(".register"),this.state!==t.State.Unregistered)throw new y.InvalidStateError('Attempt to register when device is in state "'+this.state+'". Must be "'+t.State.Unregistered+'".');return this._shouldReRegister=!1,this._setState(t.State.Registering),[4,this._streamConnectedPromise||this._setupStream()];case 1:return e.sent(),[4,this._sendPresence(!0)];case 2:return e.sent(),[4,k.promisifyEvents(this,t.State.Registered,t.State.Unregistered)];case 3:return e.sent(),[2]}})})},Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),t.prototype.toString=function(){return"[Twilio.Device instance]"},t.prototype.unregister=function(){return d(this,void 0,void 0,function(){var e,n;return l(this,function(r){switch(r.label){case 0:if(this._log.debug(".unregister"),this.state!==t.State.Registered)throw new y.InvalidStateError('Attempt to unregister when device is in state "'+this.state+'". Must be "'+t.State.Registered+'".');return this._shouldReRegister=!1,[4,this._streamConnectedPromise];case 1:return e=r.sent(),n=new Promise(function(t){e.on("offline",t)}),[4,this._sendPresence(!1)];case 2:return r.sent(),[4,n];case 3:return r.sent(),[2]}})})},t.prototype.updateOptions=function(e){if(void 0===e&&(e={}),this._logOptions("updateOptions",e),this.state===t.State.Destroyed)throw new y.InvalidStateError('Attempt to "updateOptions" when device is in state "'+this.state+'".');this._options=u(u(u({},this._defaultOptions),this._options),e);var n=new Set(this._chunderURIs),r=this._chunderURIs=(this._getChunderws()||C.getChunderURIs(this._options.edge)).map(C.createSignalingEndpointURL),i=n.size!==r.length;if(!i)for(var o=0;o<r.length;o++){var a=r[o];if(!n.has(a)){i=!0;break}}if(this.isBusy&&i)throw new y.InvalidStateError("Cannot change Edge while on an active Call");this._setupLoglevel(this._options.logLevel);for(var s=0,c=Object.keys(t._defaultSounds);s<c.length;s++){var d=c[s],l=t._defaultSounds[d],p=v.SOUNDS_BASE_URL+"/"+l.filename+"."+t.extension+"?cache="+v.RELEASE_VERSION,f=this._options.sounds&&this._options.sounds[d]||p,h=new(this._options.Sound||I.default)(d,f,{audioContext:this._options.disableAudioContextSounds?null:t.audioContext,maxDuration:l.maxDuration,shouldLoop:l.shouldLoop});this._soundcache.set(d,h)}this._setupAudioHelper(),this._setupPublisher(),i&&this._streamConnectedPromise&&this._setupStream(),"undefined"!=typeof window&&"function"==typeof window.addEventListener&&this._options.closeProtection&&(window.removeEventListener("beforeunload",this._boundConfirmClose),window.addEventListener("beforeunload",this._boundConfirmClose))},t.prototype.updateToken=function(e){if(this._log.debug(".updateToken"),this.state===t.State.Destroyed)throw new y.InvalidStateError('Attempt to "updateToken" when device is in state "'+this.state+'".');if("string"!=typeof e)throw new y.InvalidArgumentError('Parameter "token" must be of type "string".');this._token=e,this._stream&&this._stream.setToken(this._token),this._publisher&&this._publisher.setToken(this._token)},t.prototype._confirmClose=function(e){if(!this._activeCall)return"";var t=this._options.closeProtection||!1,n="string"!=typeof t?"A call is currently in-progress. Leaving or reloading this page will end the call.":t;return(e||window.event).returnValue=n,n},t.prototype._destroyAudioHelper=function(){this._audio&&(this._audio._destroy(),this._audio=null)},t.prototype._destroyPublisher=function(){this._publisher&&(this._publisher=null)},t.prototype._destroyStream=function(){this._stream&&(this._stream.removeListener("close",this._onSignalingClose),this._stream.removeListener("connected",this._onSignalingConnected),this._stream.removeListener("error",this._onSignalingError),this._stream.removeListener("invite",this._onSignalingInvite),this._stream.removeListener("offline",this._onSignalingOffline),this._stream.removeListener("ready",this._onSignalingReady),this._stream.destroy(),this._stream=null),this._onSignalingOffline(),this._streamConnectedPromise=null},t.prototype._findCall=function(e){return this._calls.find(function(t){return t.parameters.CallSid===e||t.outboundConnectionId===e})||null},t.prototype._getChunderws=function(){return"string"==typeof this._options.chunderw?[this._options.chunderw]:Array.isArray(this._options.chunderw)?this._options.chunderw:null},t.prototype._logOptions=function(e,t){void 0===t&&(t={});
1var n=["allowIncomingWhileBusy","appName","appVersion","closeProtection","codecPreferences","disableAudioContextSounds","dscp","edge","enableImprovedSignalingErrorPrecision","forceAggressiveIceNomination","logLevel","maxAverageBitrate","maxCallSignalingTimeoutMs","sounds","tokenRefreshMs"],r=["RTCPeerConnection","enumerateDevices","getUserMedia"];if("object"==typeof t){var i=u({},t);Object.keys(i).forEach(function(e){n.includes(e)||r.includes(e)||delete i[e],r.includes(e)&&(i[e]=!0)}),this._log.debug("."+e,JSON.stringify(i))}},t.prototype._makeCall=function(e,n,r){var i;return void 0===r&&(r=!1),d(this,void 0,void 0,function(){var o,a,s,c,u,d=this;return l(this,function(l){switch(l.label){case 0:if(void 0===t._isUnifiedPlanDefault)throw new y.InvalidStateError("Device has not been initialized.");if(!(o=null===(i=this._audio)||void 0===i?void 0:i._getInputDevicePromise()))return[3,2];return this._log.debug("inputDevicePromise detected, waiting..."),[4,o];case 1:l.sent(),this._log.debug("inputDevicePromise resolved"),l.label=2;case 2:return u={audioHelper:this._audio,isUnifiedPlanDefault:t._isUnifiedPlanDefault,onIgnore:function(){d._soundcache.get(t.SoundName.Incoming).stop()}},[4,this._streamConnectedPromise||this._setupStream()];case 3:return u.pstream=l.sent(),u.publisher=this._publisher,u.soundcache=this._soundcache,a=u,n=Object.assign({MediaStream:this._options.MediaStream||P.PeerConnection,RTCPeerConnection:this._options.RTCPeerConnection,beforeAccept:function(e){d._activeCall&&d._activeCall!==e&&(d._activeCall.disconnect(),d._removeCall(d._activeCall))},codecPreferences:this._options.codecPreferences,customSounds:this._options.sounds,dialtonePlayer:t._dialtonePlayer,dscp:this._options.dscp,forceAggressiveIceNomination:this._options.forceAggressiveIceNomination,getInputStream:function(){return d._options.fileInputStream||d._callInputStream},getSinkIds:function(){return d._callSinkIds},maxAverageBitrate:this._options.maxAverageBitrate,preflight:this._options.preflight,rtcConstraints:this._options.rtcConstraints,shouldPlayDisconnect:function(){var e;return null===(e=d._audio)||void 0===e?void 0:e.disconnect()},twimlParams:e,voiceEventSidGenerator:this._options.voiceEventSidGenerator},n),s=function(){if(!d._stream){d._log.warn("UnsetPreferredUri called without a stream");return}null===d._activeCall&&0===d._calls.length&&d._stream.updatePreferredURI(null)},c=new(this._options.Call||g.default)(a,n),this._publisher.info("settings","init",{RTCPeerConnection:!!this._options.RTCPeerConnection,enumerateDevices:!!this._options.enumerateDevices,getUserMedia:!!this._options.getUserMedia},c),c.once("accept",function(){d._stream.updatePreferredURI(d._preferredURI),d._removeCall(c),d._activeCall=c,d._audio&&d._audio._maybeStartPollingVolume(),c.direction===g.default.CallDirection.Outgoing&&(null===(e=d._audio)||void 0===e?void 0:e.outgoing())&&!r&&d._soundcache.get(t.SoundName.Outgoing).play();var e,n,i,o={edge:d._edge||d._region};d._options.edge&&(o.selected_edge=Array.isArray(d._options.edge)?d._options.edge:[d._options.edge]),d._publisher.info("settings","edge",o,c),(null===(n=d._audio)||void 0===n?void 0:n.processedStream)&&(null===(i=d._audioProcessorEventObserver)||void 0===i||i.emit("enabled"))}),c.addListener("error",function(e){"closed"===c.status()&&(d._removeCall(c),s()),d._audio&&d._audio._maybeStopPollingVolume(),d._maybeStopIncomingSound()}),c.once("cancel",function(){d._log.info("Canceled: "+c.parameters.CallSid),d._removeCall(c),s(),d._audio&&d._audio._maybeStopPollingVolume(),d._maybeStopIncomingSound()}),c.once("disconnect",function(){d._audio&&d._audio._maybeStopPollingVolume(),d._removeCall(c),s(),d._maybeStopIncomingSound()}),c.once("reject",function(){d._log.info("Rejected: "+c.parameters.CallSid),d._audio&&d._audio._maybeStopPollingVolume(),d._removeCall(c),s(),d._maybeStopIncomingSound()}),c.on("transportClose",function(){c.status()===g.default.State.Pending&&(d._audio&&d._audio._maybeStopPollingVolume(),d._removeCall(c),d._maybeStopIncomingSound())}),[2,c]}})})},t.prototype._maybeStopIncomingSound=function(){this._calls.length||this._soundcache.get(t.SoundName.Incoming).stop()},t.prototype._removeCall=function(e){this._activeCall===e&&(this._activeCall=null,this._makeCallPromise=null);for(var t=this._calls.length-1;t>=0;t--)e===this._calls[t]&&this._calls.splice(t,1)},t.prototype._sendPresence=function(e){return d(this,void 0,void 0,function(){var t;return l(this,function(n){switch(n.label){case 0:return[4,this._streamConnectedPromise];case 1:if(!(t=n.sent()))return[2];return t.register({audio:e}),e?this._startRegistrationTimer():this._stopRegistrationTimer(),[2]}})})},t.prototype._setState=function(e){if(e!==this.state){this._state=e;var t=this._stateEventMapping[e];
1this._log.debug("#"+t),this.emit(t)}},t.prototype._setupAudioHelper=function(){var e=this;this._audioProcessorEventObserver||(this._audioProcessorEventObserver=new m.AudioProcessorEventObserver,this._audioProcessorEventObserver.on("event",function(t){var n=t.name,r=t.group;e._publisher.info(r,n,{},e._activeCall)}));var n={audioContext:t.audioContext,audioProcessorEventObserver:this._audioProcessorEventObserver,beforeSetInputDevice:function(){return e._makeCallPromise?(e._log.debug("beforeSetInputDevice pause detected"),e._makeCallPromise):(e._log.debug("beforeSetInputDevice pause not detected, setting default"),Promise.resolve())},enumerateDevices:this._options.enumerateDevices,getUserMedia:this._options.getUserMedia||T.default};if(this._audio){this._log.info("Found existing audio helper; updating options..."),this._audio._updateUserOptions(n);return}this._audio=new(this._options.AudioHelper||h.default)(this._updateSinkIds,this._updateInputStream,n),this._audio.on("deviceChange",function(t){var n=e._activeCall,r=t.map(function(e){return e.deviceId});e._publisher.info("audio","device-change",{lost_active_device_ids:r},n),n&&n._mediaHandler._onInputDevicesChanged()})},t.prototype._setupLoglevel=function(e){var t="number"==typeof e||"string"==typeof e?e:f.levels.ERROR;this._log.setDefaultLevel(t),this._log.info("Set logger default level to",t)},t.prototype._setupPublisher=function(){var e=this;this._publisher&&(this._log.info("Found existing publisher; destroying..."),this._destroyPublisher());var t={defaultPayload:this._createDefaultPayload,metadata:{app_name:this._options.appName,app_version:this._options.appVersion}};return this._options.eventgw&&(t.host=this._options.eventgw),this._home&&(t.host=C.createEventGatewayURI(this._home)),this._publisher=new(this._options.Publisher||b.default)("twilio-js-sdk",this.token,t),!1===this._options.publishEvents?this._publisher.disable():this._publisher.on("error",function(t){e._log.warn("Cannot connect to insights.",t)}),this._publisher},t.prototype._setupStream=function(){var e=this;return this._stream&&(this._log.info("Found existing stream; destroying..."),this._destroyStream()),this._log.info("Setting up VSP"),this._stream=new(this._options.PStream||E.default)(this.token,this._chunderURIs,{backoffMaxMs:this._options.backoffMaxMs,maxPreferredDurationMs:this._options.maxCallSignalingTimeoutMs}),this._stream.addListener("close",this._onSignalingClose),this._stream.addListener("connected",this._onSignalingConnected),this._stream.addListener("error",this._onSignalingError),this._stream.addListener("invite",this._onSignalingInvite),this._stream.addListener("offline",this._onSignalingOffline),this._stream.addListener("ready",this._onSignalingReady),this._streamConnectedPromise=k.promisifyEvents(this._stream,"connected","close").then(function(){return e._stream})},t.prototype._showIncomingCall=function(e,n){var r,i=this;return Promise.race([n(),new Promise(function(e,t){r=setTimeout(function(){t(Error("Playing incoming ringtone took too long; it might not play. Continuing execution..."))},2e3)})]).catch(function(e){i._log.warn(e.message)}).then(function(){clearTimeout(r),i._log.debug("#incoming",JSON.stringify({customParameters:e.customParameters,parameters:e.parameters})),i.emit(t.EventName.Incoming,e)})},t.prototype._startRegistrationTimer=function(){var e=this;this._stopRegistrationTimer(),this._regTimer=setTimeout(function(){e._sendPresence(!0)},3e4)},t.prototype._stopRegistrationTimer=function(){this._regTimer&&clearTimeout(this._regTimer)},t.prototype._throwIfDestroyed=function(){if(this.state===t.State.Destroyed)throw new y.InvalidStateError("Device has been destroyed.")},t.prototype._updateRingtoneSinkIds=function(e){return Promise.resolve(this._soundcache.get(t.SoundName.Incoming).setSinkIds(e))},t.prototype._updateSpeakerSinkIds=function(e){Array.from(this._soundcache.entries()).filter(function(e){return e[0]!==t.SoundName.Incoming}).forEach(function(t){return t[1].setSinkIds(e)}),this._callSinkIds=e;var n=this._activeCall;return n?n._setSinkIds(e):Promise.resolve()},t._defaultSounds={disconnect:{filename:"disconnect",maxDuration:3e3},dtmf0:{filename:"dtmf-0",maxDuration:1e3},dtmf1:{filename:"dtmf-1",maxDuration:1e3},dtmf2:{filename:"dtmf-2",maxDuration:1e3},dtmf3:{filename:"dtmf-3",maxDuration:1e3},dtmf4:{filename:"dtmf-4",maxDuration:1e3}
1,dtmf5:{filename:"dtmf-5",maxDuration:1e3},dtmf6:{filename:"dtmf-6",maxDuration:1e3},dtmf7:{filename:"dtmf-7",maxDuration:1e3},dtmf8:{filename:"dtmf-8",maxDuration:1e3},dtmf9:{filename:"dtmf-9",maxDuration:1e3},dtmfh:{filename:"dtmf-hash",maxDuration:1e3},dtmfs:{filename:"dtmf-star",maxDuration:1e3},incoming:{filename:"incoming",shouldLoop:!0},outgoing:{filename:"outgoing",maxDuration:3e3}},t}(p.EventEmitter);(o=(i=R||(R={})).EventName||(i.EventName={})).Error="error",o.Incoming="incoming",o.Destroyed="destroyed",o.Unregistered="unregistered",o.Registering="registering",o.Registered="registered",o.TokenWillExpire="tokenWillExpire",(a=i.State||(i.State={})).Destroyed="destroyed",a.Unregistered="unregistered",a.Registering="registering",a.Registered="registered",(s=i.SoundName||(i.SoundName={})).Incoming="incoming",s.Outgoing="outgoing",s.Disconnect="disconnect",s.Dtmf0="dtmf0",s.Dtmf1="dtmf1",s.Dtmf2="dtmf2",s.Dtmf3="dtmf3",s.Dtmf4="dtmf4",s.Dtmf5="dtmf5",s.Dtmf6="dtmf6",s.Dtmf7="dtmf7",s.Dtmf8="dtmf8",s.Dtmf9="dtmf9",s.DtmfS="dtmfs",s.DtmfH="dtmfh",t.default=R},39324:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(12861),i={dtmf0:[1360,960],dtmf1:[1230,720],dtmf2:[1360,720],dtmf3:[1480,720],dtmf4:[1230,790],dtmf5:[1360,790],dtmf6:[1480,790],dtmf7:[1230,870],dtmf8:[1360,870],dtmf9:[1480,870],dtmfh:[1480,960],dtmfs:[1230,960]},o=function(){function e(e){var t=this;this._context=e,this._gainNodes=[],this._gainNodes=[this._context.createGain(),this._context.createGain()],this._gainNodes.forEach(function(e){e.connect(t._context.destination),e.gain.value=.1,t._gainNodes.push(e)})}return e.prototype.cleanup=function(){this._gainNodes.forEach(function(e){e.disconnect()})},e.prototype.play=function(e){var t=this,n=i[e];if(!n)throw new r.InvalidArgumentError("Invalid DTMF sound name");[this._context.createOscillator(),this._context.createOscillator()].forEach(function(e,r){e.type="sine",e.frequency.value=n[r],e.connect(t._gainNodes[r]),e.start(),e.stop(t._context.currentTime+.1),e.addEventListener("ended",function(){return e.disconnect()})})},e}();t.default=o},27669:function(e,t,n){"use strict";var r,i,o,a,s,c,u,d,l,p,f,h,m,g,v,_,y,b,S,w,E,C,P,T,I,k,x,R,O,A,D,M,j,L,N,U,F,V,B,W,G,H,q,z,J,K,Q,X,Y,$,Z,ee,et,en,er,ei,eo,ea,es,ec=this&&this.__extends||($=function(e,t){return($=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}$(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.errorsByCode=t.MediaErrors=t.SignalingErrors=t.UserMediaErrors=t.MalformedRequestErrors=t.GeneralErrors=t.SIPServerErrors=t.ClientErrors=t.SignatureValidationErrors=t.AuthorizationErrors=t.TwilioError=void 0;var eu=n(6908);t.TwilioError=eu.default,r=Z=t.AuthorizationErrors||(t.AuthorizationErrors={}),i=function(e){function t(t,n){var i=e.call(this,t,n)||this;i.causes=[],i.code=20101,i.description="Invalid access token",i.explanation="Twilio was unable to validate your Access Token",i.name="Acce
1ssTokenInvalid",i.solutions=[],Object.setPrototypeOf(i,r.AccessTokenInvalid.prototype);var o="string"==typeof t?t:i.explanation,a="object"==typeof t?t:n;return i.message=i.name+" ("+i.code+"): "+o,i.originalError=a,i}return ec(t,e),t}(eu.default),r.AccessTokenInvalid=i,o=function(e){function t(t,n){var i=e.call(this,t,n)||this;i.causes=[],i.code=20104,i.description="Access token expired or expiration date invalid",i.explanation="The Access Token provided to the Twilio API has expired, the expiration time specified in the token was invalid, or the expiration time specified was too far in the future",i.name="AccessTokenExpired",i.solutions=[],Object.setPrototypeOf(i,r.AccessTokenExpired.prototype);var o="string"==typeof t?t:i.explanation,a="object"==typeof t?t:n;return i.message=i.name+" ("+i.code+"): "+o,i.originalError=a,i}return ec(t,e),t}(eu.default),r.AccessTokenExpired=o,a=function(e){function t(t,n){var i=e.call(this,t,n)||this;i.causes=[],i.code=20151,i.description="Authentication Failed",i.explanation="The Authentication with the provided JWT failed",i.name="AuthenticationFailed",i.solutions=[],Object.setPrototypeOf(i,r.AuthenticationFailed.prototype);var o="string"==typeof t?t:i.explanation,a="object"==typeof t?t:n;return i.message=i.name+" ("+i.code+"): "+o,i.originalError=a,i}return ec(t,e),t}(eu.default),r.AuthenticationFailed=a,s=ee=t.SignatureValidationErrors||(t.SignatureValidationErrors={}),c=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["The access token has an invalid Account SID, API Key, or API Key Secret."],r.code=31202,r.description="Signature validation failed.",r.explanation="The provided access token failed signature validation.",r.name="AccessTokenSignatureValidationFailed",r.solutions=["Ensure the Account SID, API Key, and API Key Secret are valid when generating your access token."],Object.setPrototypeOf(r,s.AccessTokenSignatureValidationFailed.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),s.AccessTokenSignatureValidationFailed=c,u=et=t.ClientErrors||(t.ClientErrors={}),d=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31400,r.description="Bad Request (HTTP/SIP)",r.explanation="The request could not be understood due to malformed syntax.",r.name="BadRequest",r.solutions=[],Object.setPrototypeOf(r,u.BadRequest.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),u.BadRequest=d,l=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["The outbound call was made to an invalid phone number.","The TwiML application sid is missing a Voice URL."],r.code=31404,r.description="Not Found (HTTP/SIP)",r.explanation="The server has not found anything matching the request.",r.name="NotFound",r.solutions=["Ensure the phone number dialed is valid.","Ensure the TwiML application is configured correctly with a Voice URL link."],Object.setPrototypeOf(r,u.NotFound.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),u.NotFound=l,p=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31480,r.description="Temporarily Unavailable (SIP)",r.explanation="The callee is currently unavailable.",r.name="TemporarilyUnavailable",r.solutions=[],Object.setPrototypeOf(r,u.TemporarilyUnavailable.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),u.TemporarilyUnavailable=p,f=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31486,r.description="Busy Here (SIP)",r.explanation="The callee is busy.",r.name="BusyHere",r.solutions=[],Object.setPrototypeOf(r,u.BusyHere.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),u.BusyHere=f,h=en=t.SIPServerErrors||(t.SIPServerErrors={}),m=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31603,r.description="Decline (SIP)",r.explanation="The callee does not wish to participate in the call.",r.name="Decline",r.solutions=[],Object.setPrototypeOf(r,h.Decline.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),h.Decline=m,g=er=t.GeneralErrors||(t.GeneralErrors={}),v=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31e3,r.description="Unknown Error",r.explanation="An unknown error has occurred. See error details for more information.",r.n
1ame="UnknownError",r.solutions=[],Object.setPrototypeOf(r,g.UnknownError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),g.UnknownError=v,_=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31001,r.description="Application Not Found",r.explanation="",r.name="ApplicationNotFoundError",r.solutions=[],Object.setPrototypeOf(r,g.ApplicationNotFoundError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),g.ApplicationNotFoundError=_,y=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31002,r.description="Connection Declined",r.explanation="",r.name="ConnectionDeclinedError",r.solutions=[],Object.setPrototypeOf(r,g.ConnectionDeclinedError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),g.ConnectionDeclinedError=y,b=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31003,r.description="Connection Timeout",r.explanation="The server could not produce a response within a suitable amount of time.",r.name="ConnectionTimeoutError",r.solutions=[],Object.setPrototypeOf(r,g.ConnectionTimeoutError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),g.ConnectionTimeoutError=b,S=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31005,r.description="Connection error",r.explanation="A connection error occurred during the call",r.name="ConnectionError",r.solutions=[],Object.setPrototypeOf(r,g.ConnectionError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),g.ConnectionError=S,w=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["The incoming call was cancelled because it was not answered in time or it was accepted/rejected by another application instance registered with the same identity."],r.code=31008,r.description="Call cancelled",r.explanation="Unable to answer because the call has ended",r.name="CallCancelledError",r.solutions=[],Object.setPrototypeOf(r,g.CallCancelledError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),g.CallCancelledError=w,E=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31009,r.description="Transport error",r.explanation="No transport available to send or receive messages",r.name="TransportError",r.solutions=[],Object.setPrototypeOf(r,g.TransportError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),g.TransportError=E,C=ei=t.MalformedRequestErrors||(t.MalformedRequestErrors={}),P=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["Invalid content or MessageType passed to sendMessage method."],r.code=31100,r.description="The request had malformed syntax.",r.explanation="The request could not be understood due to malformed syntax.",r.name="MalformedRequestError",r.solutions=["Ensure content and MessageType passed to sendMessage method are valid."],Object.setPrototypeOf(r,C.MalformedRequestError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),C.MalformedRequestError=P,T=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31101,r.description="Missing parameter array in request",r.explanation="",r.name="MissingParameterArrayError",r.solutions=[],Object.setPrototypeOf(r,C.MissingParameterArrayError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),C.MissingParameterArrayError=T,I=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31102,r.description="Authorization token missing in request.",r.explanation="",r.name="AuthorizationTokenMissingError",r.solutions=[],Object.setPrototypeOf(r,C.AuthorizationTokenMissingError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),C.AuthorizationTokenMissingError=I,k=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31103,r.description="Maximum parameter length has been exceeded.",r.explanation="Length of parameters cannot exceed MAX_PARAM_LENGTH.",r.name="MaxParameterLengthExceededError",r.solutions=[],Object.setPrototypeOf(r,C.MaxParameterLengthExceededError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),C.MaxParameterLengthExceededError=k,x=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31104,r.description="Invalid bridge token",r.explanation="",r.name="InvalidBridgeTokenError",r.solutions=[],Object.setPrototypeOf(r,C.InvalidBridgeTokenError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),C.InvalidBridgeTokenError=x,R=function(e){function t(t,n){var r=e.call(this,t,n)||this;
1r.causes=["Client name contains invalid characters."],r.code=31105,r.description="Invalid client name",r.explanation="Client name should not contain control, space, delims, or unwise characters.",r.name="InvalidClientNameError",r.solutions=["Make sure that client name does not contain any of the invalid characters."],Object.setPrototypeOf(r,C.InvalidClientNameError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),C.InvalidClientNameError=R,O=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31107,r.description="The reconnect parameter is invalid",r.explanation="",r.name="ReconnectParameterInvalidError",r.solutions=[],Object.setPrototypeOf(r,C.ReconnectParameterInvalidError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),C.ReconnectParameterInvalidError=O,A=Z=t.AuthorizationErrors||(t.AuthorizationErrors={}),D=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31201,r.description="Authorization error",r.explanation="The request requires user authentication. The server understood the request, but is refusing to fulfill it.",r.name="AuthorizationError",r.solutions=[],Object.setPrototypeOf(r,A.AuthorizationError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),A.AuthorizationError=D,M=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31203,r.description="No valid account",r.explanation="",r.name="NoValidAccountError",r.solutions=[],Object.setPrototypeOf(r,A.NoValidAccountError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),A.NoValidAccountError=M,j=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31204,r.description="Invalid JWT token",r.explanation="",r.name="InvalidJWTTokenError",r.solutions=[],Object.setPrototypeOf(r,A.InvalidJWTTokenError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),A.InvalidJWTTokenError=j,L=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31205,r.description="JWT token expired",r.explanation="",r.name="JWTTokenExpiredError",r.solutions=[],Object.setPrototypeOf(r,A.JWTTokenExpiredError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),A.JWTTokenExpiredError=L,N=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["Rate limit exceeded."],r.code=31206,r.description="Rate exceeded authorized limit.",r.explanation="The request performed exceeds the authorized limit.",r.name="RateExceededError",r.solutions=["Ensure message send rate does not exceed authorized limits."],Object.setPrototypeOf(r,A.RateExceededError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}
1(eu.default),A.RateExceededError=N,U=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31207,r.description="JWT token expiration too long",r.explanation="",r.name="JWTTokenExpirationTooLongError",r.solutions=[],Object.setPrototypeOf(r,A.JWTTokenExpirationTooLongError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),A.JWTTokenExpirationTooLongError=U,F=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=31209,r.description="Reconnect attempt is not authorized.",r.explanation="",r.name="ReconnectAttemptError",r.solutions=[],Object.setPrototypeOf(r,A.ReconnectAttemptError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),A.ReconnectAttemptError=F,V=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["The Call Message Event Type is invalid and is not understood by Twilio Voice."],r.code=31210,r.description="Call Message Event Type is invalid.",r.explanation="The Call Message Event Type is invalid and is not understood by Twilio Voice.",r.name="CallMessageEventTypeInvalidError",r.solutions=["Ensure the Call Message Event Type is Valid and understood by Twilio Voice and try again."],Object.setPrototypeOf(r,A.CallMessageEventTypeInvalidError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),A.CallMessageEventTypeInvalidError=V,B=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["The payload size of Call Message Event exceeds the authorized limit."],r.code=31212,r.description="Call Message Event Payload size exceeded authorized limit.",r.explanation="The request performed to send a Call Message Event exceeds the payload size authorized limit",r.name="PayloadSizeExceededError",r.solutions=["Reduce payload size of Call Message Event to be within the authorized limit and try again."],Object.setPrototypeOf(r,A.PayloadSizeExceededError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),A.PayloadSizeExceededError=B,W=eo=t.UserMediaErrors||(t.UserMediaErrors={}),G=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["The user denied the getUserMedia request.","The browser denied the getUserMedia request."],r.code=31401,r.description="UserMedia Permission Denied Error",r.explanation="The browser or end-user denied permissions to user media. Therefore we were unable to acquire input audio.",r.name="PermissionDeniedError",r.solutions=["The user should accept the request next time prompted. If the browser saved the deny, the user should change that permission in their browser.","The user should to verify that the browser has permission to access the microphone at this address."],Object.setPrototypeOf(r,W.PermissionDeniedError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),W.PermissionDeniedError=G,H=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["NotFoundError - The deviceID specified was not found.","The getUserMedia constraints were overconstrained and no devices matched."],r.code=31402,r.description="UserMedia Acquisition Failed Error",r.explanation="The browser and end-user allowed permissions, however getting the media failed. Usually this is due to bad constraints, but can sometimes fail due to browser, OS or hardware issues.",r.name="AcquisitionFailedError",r.solutions=["Ensure the deviceID being specified exists.","Try acquiring media with fewer constraints."],Object.setPrototypeOf(r,W.AcquisitionFailedError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),W.AcquisitionFailedError=H,q=ea=t.SignalingErrors||(t.SignalingErrors={}),z=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=[],r.code=53e3,r.description="Signaling connection error",r.explanation="Raised whenever a signaling connection error occurs that is not covered by a more specific error code.",r.name="ConnectionError",r.solutions=[],Object.setPrototypeOf(r,q.ConnectionError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),q.ConnectionError=z,J=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["The device running your application lost its Internet connection."],r.code=53001,r.description="Signaling connection disconnected",r.explanation="Raised whenever the signaling connection is unexpectedly disconnected.",r.n
1ame="ConnectionDisconnected",r.solutions=["Ensure the device running your application has access to a stable Internet connection."],Object.setPrototypeOf(r,q.ConnectionDisconnected.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),q.ConnectionDisconnected=J,K=es=t.MediaErrors||(t.MediaErrors={}),Q=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["The Client may not be using a supported WebRTC implementation.","The Client may not have the necessary resources to create or apply a new media description."],r.code=53400,r.description="Client is unable to create or apply a local media description",r.explanation="Raised whenever a Client is unable to create or apply a local media description.",r.name="ClientLocalDescFailed",r.solutions=["If you are experiencing this error using the JavaScript SDK, ensure you are running it with a supported WebRTC implementation."],Object.setPrototypeOf(r,K.ClientLocalDescFailed.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),K.ClientLocalDescFailed=Q,X=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["The Client may not be using a supported WebRTC implementation.","The Client may be connecting peer-to-peer with another Participant that is not using a supported WebRTC implementation.","The Client may not have the necessary resources to apply a new media description."],r.code=53402,r.description="Client is unable to apply a remote media description",r.explanation="Raised whenever the Client receives a remote media description but is unable to apply it.",r.name="ClientRemoteDescFailed",r.solutions=["If you are experiencing this error using the JavaScript SDK, ensure you are running it with a supported WebRTC implementation."],Object.setPrototypeOf(r,K.ClientRemoteDescFailed.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),K.ClientRemoteDescFailed=X,Y=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.causes=["The Client was unable to establish a media connection.","A media connection which was active failed liveliness checks."],r.code=53405,r.description="Media connection failed",r.explanation="Raised by the Client or Server whenever a media connection fails.",r.name="ConnectionError",r.solutions=["If the problem persists, try connecting to another region.","Check your Client's network connectivity.","If you've provided custom ICE Servers then ensure that the URLs and credentials are valid."],Object.setPrototypeOf(r,K.ConnectionError.prototype);var i="string"==typeof t?t:r.explanation,o="object"==typeof t?t:n;return r.message=r.name+" ("+r.code+"): "+i,r.originalError=o,r}return ec(t,e),t}(eu.default),K.ConnectionError=Y,t.errorsByCode=new Map([[20101,Z.AccessTokenInvalid],[20104,Z.AccessTokenExpired],[20151,Z.AuthenticationFailed],[31202,ee.AccessTokenSignatureValidationFailed],[31400,et.BadRequest],[31404,et.NotFound],[31480,et.TemporarilyUnavailable],[31486,et.BusyHere],[31603,en.Decline],[31e3,er.UnknownError],[31001,er.ApplicationNotFoundError],[31002,er.ConnectionDeclinedError],[31003,er.ConnectionTimeoutError],[31005,er.ConnectionError],[31008,er.CallCancelledError],[31009,er.TransportError],[31100,ei.MalformedRequestError],[31101,ei.MissingParameterArrayError],[31102,ei.AuthorizationTokenMissingError],[31103,ei.MaxParameterLengthExceededError],[31104,ei.InvalidBridgeTokenError],[31105,ei.InvalidClientNameError],[31107,ei.ReconnectParameterInvalidError],[31201,Z.AuthorizationError],[31203,Z.NoValidAccountError],[31204,Z.InvalidJWTTokenError],[31205,Z.JWTTokenExpiredError],[31206,Z.RateExceededError],[31207,Z.JWTTokenExpirationTooLongError],[31209,Z.ReconnectAttemptError],[31210,Z.CallMessageEventTypeInvalidError],[31212,Z.PayloadSizeExceededError],[31401,eo.PermissionDeniedError],[31402,eo.AcquisitionFailedError],[53e3,ea.ConnectionError],[53001,ea.ConnectionDisconnected],[53400,es.ClientLocalDescFailed],[53402,es.ClientRemoteDescFailed],[53405,es.
1ConnectionError]]),Object.freeze(t.errorsByCode)},12861:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.UserMediaErrors=t.TwilioError=t.SIPServerErrors=t.SignatureValidationErrors=t.SignalingErrors=t.MediaErrors=t.MalformedRequestErrors=t.GeneralErrors=t.ClientErrors=t.AuthorizationErrors=t.hasErrorByCode=t.getErrorByCode=t.NotSupportedError=t.InvalidStateError=t.InvalidArgumentError=t.getPreciseSignalingErrorByCode=void 0;var o=n(27669);Object.defineProperty(t,"AuthorizationErrors",{enumerable:!0,get:function(){return o.AuthorizationErrors}}),Object.defineProperty(t,"ClientErrors",{enumerable:!0,get:function(){return o.ClientErrors}}),Object.defineProperty(t,"GeneralErrors",{enumerable:!0,get:function(){return o.GeneralErrors}}),Object.defineProperty(t,"MalformedRequestErrors",{enumerable:!0,get:function(){return o.MalformedRequestErrors}}),Object.defineProperty(t,"MediaErrors",{enumerable:!0,get:function(){return o.MediaErrors}}),Object.defineProperty(t,"SignalingErrors",{enumerable:!0,get:function(){return o.SignalingErrors}}),Object.defineProperty(t,"SignatureValidationErrors",{enumerable:!0,get:function(){return o.SignatureValidationErrors}}),Object.defineProperty(t,"SIPServerErrors",{enumerable:!0,get:function(){return o.SIPServerErrors}}),Object.defineProperty(t,"TwilioError",{enumerable:!0,get:function(){return o.TwilioError}}),Object.defineProperty(t,"UserMediaErrors",{enumerable:!0,get:function(){return o.UserMediaErrors}});var a=new Set([31001,31002,31003,31101,31102,31103,31104,31105,31107,31201,31202,31203,31204,31205,31207,31404,31480,31486,31603]);t.getPreciseSignalingErrorByCode=function(e,t){if("number"==typeof t&&l(t)&&(e||!a.has(t)))return d(t)};var s=function(e){function t(t){var n=e.call(this,t)||this;return n.name="InvalidArgumentError",n}return i(t,e),t}(Error);t.InvalidArgumentError=s;var c=function(e){function t(t){var n=e.call(this,t)||this;return n.name="InvalidStateError",n}return i(t,e),t}(Error);t.InvalidStateError=c;var u=function(e){function t(t){var n=e.call(this,t)||this;return n.name="NotSupportedError",n}return i(t,e),t}(Error);function d(e){var t=o.errorsByCode.get(e);if(!t)throw new s("Error code "+e+" not found");return t}function l(e){return o.errorsByCode.has(e)}t.NotSupportedError=u,t.getErrorByCode=d,t.hasErrorByCode=l},6908:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var i=function(e){function t(n,r){var i=e.call(this)||this;Object.setPrototypeOf(i,t.prototype);var o="string"==typeof n?n:i.explanation;return i.message=i.name+" ("+i.code+"): "+o,i.originalError="object"==typeof n?n:r,i}return r(t,e),t}(Error);t.default=i},30821:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(55445),a=n(92764),s=n(24400),c=function(e){function t(n,r,i){var o=e.call(this)||this;if(!(o instanceof t))return new t(n,r,i);var c=(i=Object.assign({defaultPayload:function(){return{}}},i)).defaultPayload;"function"!=typeof c&&(c=function(){return Object.assign({},i.defaultPayload)});var u=!0,d=Object.assign({app_name:void 0,app_version:void 0},i.metadata);return Object.defineProperties(o,{_defaultPayload:{value:c},_host:{value:i.host,writable:!0},_isEnabled:{get:function(){return u},set:function(e){u=e}},_log:{value:new a.default("EventPublisher")},_request:{value:i.request||s.default,writable:!0},_token:{value:r,writable:!0},isEnabled:{enumerable:!0,get:function(){return u}},metadata:{enumerable:!0,get:function(){return d}},productName:{enumerable:!0,value:n},token:{enumerable:!0,get:function(){return this._token}}}),o}return i(t,e),t}(o.EventEmitter);function u(e){return{audio_codec:e.codecName,audio_level_in:e.audioInput
1Level,audio_level_out:e.audioOutputLevel,bytes_received:e.bytesReceived,bytes_sent:e.bytesSent,call_volume_input:e.inputVolume,call_volume_output:e.outputVolume,jitter:e.jitter,mos:e.mos&&Math.round(100*e.mos)/100,packets_lost:e.packetsLost,packets_lost_fraction:e.packetsLostFraction&&Math.round(100*e.packetsLostFraction)/100,packets_received:e.packetsReceived,rtt:e.rtt,timestamp:new Date(e.timestamp).toISOString(),total_bytes_received:e.totals.bytesReceived,total_bytes_sent:e.totals.bytesSent,total_packets_lost:e.totals.packetsLost,total_packets_received:e.totals.packetsReceived,total_packets_sent:e.totals.packetsSent}}c.prototype._post=function(e,t,n,r,i,o,a){var s=this;if(!this.isEnabled&&!a||!this._host)return this._log.debug("Publishing cancelled",JSON.stringify({isEnabled:this.isEnabled,force:a,host:this._host})),Promise.resolve();if(!o||(!o.parameters||!o.parameters.CallSid)&&!o.outboundConnectionId)return o?this._log.debug("Publishing cancelled. Missing connection info",JSON.stringify({outboundConnectionId:o.outboundConnectionId,parameters:o.parameters})):this._log.debug("Publishing cancelled. Missing connection object"),Promise.resolve();var c={group:n,level:t.toUpperCase(),name:r,payload:i&&i.forEach?i.slice(0):Object.assign(this._defaultPayload(o),i),payload_type:"application/json",private:!1,publisher:this.productName,timestamp:new Date().toISOString()};this.metadata&&(c.publisher_metadata=this.metadata),"EndpointEvents"===e&&this._log.debug("Publishing insights",JSON.stringify({endpointName:e,event:c,force:a,host:this._host}));var u={body:c,headers:{"Content-Type":"application/json","X-Twilio-Token":this.token},url:"https://"+this._host+"/v4/"+e};return new Promise(function(e,t){s._request.post(u,function(n){n?(s.emit("error",n),t(n)):e()})}).catch(function(e){s._log.error("Unable to post "+n+" "+r+" event to Insights. Received error: "+e)})},c.prototype.post=function(e,t,n,r,i,o){return this._post("EndpointEvents",e,t,n,r,i,o)},c.prototype.debug=function(e,t,n,r){return this.post("debug",e,t,n,r)},c.prototype.info=function(e,t,n,r){return this.post("info",e,t,n,r)},c.prototype.warn=function(e,t,n,r){return this.post("warning",e,t,n,r)},c.prototype.error=function(e,t,n,r){return this.post("error",e,t,n,r)},c.prototype.postMetrics=function(e,t,n,r,i){var o=this;return new Promise(function(a){var s=n.map(u).map(function(e){return Object.assign(e,r)});a(o._post("EndpointMetrics","info",e,t,s,i))})},c.prototype.setHost=function(e){this._host=e},c.prototype.setToken=function(e){this._token=e},c.prototype.enable=function(){this._isEnabled=!0},c.prototype.disable=function(){this._isEnabled=!1},t.default=c},92764:function(e,t,n){"use strict";var r=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r};Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=void 0;var i=n(86005),o=n(6501),a=function(){function e(t,n){this._log=e.getLogLevelInstance(n),this._prefix="[TwilioVoice]["+t+"]"}return e.getLogLevelInstance=function(t){if(!e.loglevelInstance)try{e.loglevelInstance=(t&&t.LogLevelModule?t.LogLevelModule:i).getLogger(o.PACKAGE_NAME)}catch(t){console.warn("Cannot create custom logger"),e.loglevelInstance=console}return e.loglevelInstance},e.prototype.debug=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this._log).debug.apply(e,r([this._prefix],t))},e.prototype.error=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this._log).error.apply(e,r([this._prefix],t))},e.prototype.info=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this._log).info.apply(e,r([this._prefix],t))},e.prototype.setDefaultLevel=function(e){this._log.setDefaultLevel?this._log.setDefaultLevel(e):console.warn("Logger cannot setDefaultLevel")},e.prototype.warn=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this._log).warn.apply(e,r([this._prefix],t))},e.levels=i.levels,e}();t.Logger=a.getLogLevelInstance(),t.default=a},37244:function(e,t,n){"use strict";
1Object.defineProperty(t,"__esModule",{value:!0});var r=n(6501),i=n(12861),o=n(92764),a=r.SOUNDS_BASE_URL+"/outgoing.mp3",s=function(){function e(e,t,n,r){this._name=e,this._availableDevices=t,this._beforeChange=n,this._isSupported=r,this._activeDevices=new Set,this._log=new o.default("OutputDeviceCollection")}return e.prototype.delete=function(e){this._log.debug(".delete",e);var t=!!this._activeDevices.delete(e),n=this._availableDevices.get("default")||Array.from(this._availableDevices.values())[0];!this._activeDevices.size&&n&&this._activeDevices.add(n);var r=Array.from(this._activeDevices.values()).map(function(e){return e.deviceId});return this._beforeChange(this._name,r),!!t},e.prototype.get=function(){return this._activeDevices},e.prototype.set=function(e){var t=this;if(this._log.debug(".set",e),!this._isSupported)return Promise.reject(new i.NotSupportedError("This browser does not support audio output selection"));var n=Array.isArray(e)?e:[e];if(!n.length)return Promise.reject(new i.InvalidArgumentError("Must specify at least one device to set"));var r=[],o=n.map(function(e){var n=t._availableDevices.get(e);return n||r.push(e),n});return r.length?Promise.reject(new i.InvalidArgumentError("Devices not found: "+r.join(", "))):new Promise(function(e){e(t._beforeChange(t._name,n))}).then(function(){t._activeDevices.clear(),o.forEach(t._activeDevices.add,t._activeDevices)})},e.prototype.test=function(e){return(void 0===e&&(e=a),this._isSupported)?this._activeDevices.size?Promise.all(Array.from(this._activeDevices).map(function(t){var n;return new Promise(function(t){(n=new Audio(e)).oncanplay=t}).then(function(){return n.setSinkId(t.deviceId).then(function(){return n.play()})})})):Promise.reject(new i.InvalidStateError("No active output devices to test")):Promise.reject(new i.NotSupportedError("This browser does not support audio output selection"))},e}();t.default=s},7562:function(e,t,n){"use strict";var r,i,o,a,s,c=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),u=this&&this.__assign||function(){return(u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},d=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})},l=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.PreflightTest=void 0;var p=n(55445),f=n(22534),h=n(65718),m=n(12861),g=n(92764),v=n(11082),_=n(6501),y=function(e){function t(n,r){var i=e.call(this)||this;i._hasInsightsErrored=!1,i._log=new g.default("PreflightTest"),i._networkTiming={},i._options={codecPreferences:[f.default.Codec.PCMU,f.default.Codec.Opus],edge:"roaming",fakeMicInput
1:!1,logLevel:"error",signalingTimeoutMs:1e4},i._status=t.Status.Connecting,Object.assign(i._options,r),i._samples=[],i._warnings=[],i._startTime=Date.now(),i._initDevice(n,u(u({},i._options),{fileInputStream:i._options.fakeMicInput?i._getStreamFromFile():void 0}));var o=["codecPreferences","edge","fakeMicInput","logLevel","signalingTimeoutMs"],a=["audioContext","deviceFactory","fileInputStream","getRTCIceCandidateStatsReport","iceServers","rtcConfiguration"];if("object"==typeof r){var s=u({},r);Object.keys(s).forEach(function(e){o.includes(e)||a.includes(e)||delete s[e],a.includes(e)&&(s[e]=!0)}),i._log.debug(".constructor",JSON.stringify(s))}return i}return c(t,e),t.prototype.stop=function(){var e=this;this._log.debug(".stop");var t=new m.GeneralErrors.CallCancelledError;this._device?(this._device.once(h.default.EventName.Unregistered,function(){return e._onFailed(t)}),this._device.destroy()):this._onFailed(t)},t.prototype._emitWarning=function(e,n,r){var i={name:e,description:n};r&&(i.rtcWarning=r),this._warnings.push(i),this._log.debug("#"+t.Events.Warning,JSON.stringify(i)),this.emit(t.Events.Warning,i)},t.prototype._getCallQuality=function(e){return e>4.2?t.CallQuality.Excellent:e>=4.1&&e<=4.2?t.CallQuality.Great:e>=3.7&&e<=4?t.CallQuality.Good:e>=3.1&&e<=3.6?t.CallQuality.Fair:t.CallQuality.Degraded},t.prototype._getReport=function(){var e,t,n,r=this._getRTCStats(),i={start:this._startTime};this._endTime&&(i.end=this._endTime,i.duration=this._endTime-this._startTime);var o={callSid:this._callSid,edge:this._edge,iceCandidateStats:null!==(t=null===(e=this._rtcIceCandidateStatsReport)||void 0===e?void 0:e.iceCandidateStats)&&void 0!==t?t:[],networkTiming:this._networkTiming,samples:this._samples,selectedEdge:this._options.edge,stats:r,testTiming:i,totals:this._getRTCSampleTotals(),warnings:this._warnings},a=null===(n=this._rtcIceCandidateStatsReport)||void 0===n?void 0:n.selectedIceCandidatePairStats;return a&&(o.selectedIceCandidatePairStats=a,o.isTurnRequired="relay"===a.localCandidate.candidateType||"relay"===a.remoteCandidate.candidateType),r&&(o.callQuality=this._getCallQuality(r.mos.average)),o},t.prototype._getRTCSampleTotals=function(){if(this._latestSample)return u({},this._latestSample.totals)},t.prototype._getRTCStats=function(){var e=this._samples.findIndex(function(e){return"number"==typeof e.mos&&e.mos>0}),t=e>=0?this._samples.slice(e):[];if(t&&t.length)return["jitter","mos","rtt"].reduce(function(e,n){var r,i=t.map(function(e){return e[n]});return u(u({},e),((r={})[n]={average:Number((i.reduce(function(e,t){return e+t})/i.length).toPrecision(5)),max:Math.max.apply(Math,i),min:Math.min.apply(Math,i)},r))},{})},t.prototype._getStreamFromFile=function(){var e=this._options.audioContext;if(!e)throw new m.NotSupportedError("Cannot fake input audio stream: AudioContext is not supported by this browser.");var t=new Audio(_.COWBELL_AUDIO_URL);t.addEventListener("canplaythrough",function(){return t.play()}),"function"==typeof t.setAttribute&&t.setAttribute("crossorigin","anonymous");var n=e.createMediaElementSource(t),r=e.createMediaStreamDestination();return n.connect(r),r.stream},t.prototype._initDevice=function(e,t){var n=this;try{this._device=new(t.deviceFactory||h.default)(e,{chunderw:t.chunderw,codecPreferences:t.codecPreferences,edge:t.edge,eventgw:t.eventgw,fileInputStream:t.fileInputStream,logLevel:t.logLevel,preflight:!0}),this._device.once(h.default.EventName.Registered,function(){n._onDeviceRegistered()}),this._device.once(h.default.EventName.Error,function(e){n._onDeviceError(e)}),this._device.register()}catch(e){setTimeout(function(){n._onFailed(e)});return}this._signalingTimeoutTimer=setTimeout(function(){n._onDeviceError(new m.SignalingErrors.ConnectionError("WebSocket Connection Timeout"))},t.signalingTimeoutMs)},t.prototype._onDeviceError=function(e){this._device.destroy(),this._onFailed(e)},t.prototype._onDeviceRegistered=function(){return d(this,void 0,void 0,function(){var e,t,n=this;return l(this,function(r){switch(r.label){case 0:return clearTimeout(this._echoTimer),clearTimeout(this._signalingTimeoutTimer),e=this,[4,this._device.connect({rtcConfiguration:this._options.rtcConfiguration})];case 1:return e._call=r.sent(),this._networkTiming.signaling={start:Date.now()},this._setupCallHandlers(this._call),this._edge=this._device.edge||void 0,this._options.fakeMicInput&&(this._echoTimer=setTimeout(function(){return n._device.disconnectAll()},_.ECHO_TEST_DURATION),(t=this._device.audio)&&(t.disconnect(!1),t.outgoing(!1))),this._call.once("disconnect",function(){n._device.once(h.default.EventName.Unregistered,function(){return n._onUnregistered()}),n._device.destroy()}),this._call._publisher.on("error",function(){n._hasInsightsErrored||n._emitWarning("insights-connection-error","Received an error when attempting to connect to Insights gateway"),n._hasInsightsErrored=!0}),[2]}})})},t.prototype._onFailed=function(e){clearTimeout(this._echoTimer),clearTimeout(this._signalingTimeoutTimer),this._releaseHandlers(),this._endTime=Date.now(),this._status=t.Status.Failed,this._log.debug("#"+t.Events.Failed,e),this.emit
1(t.Events.Failed,e)},t.prototype._onUnregistered=function(){var e=this;setTimeout(function(){e._status!==t.Status.Failed&&(clearTimeout(e._echoTimer),clearTimeout(e._signalingTimeoutTimer),e._releaseHandlers(),e._endTime=Date.now(),e._status=t.Status.Completed,e._report=e._getReport(),e._log.debug("#"+t.Events.Completed,JSON.stringify(e._report)),e.emit(t.Events.Completed,e._report))},10)},t.prototype._releaseHandlers=function(){[this._device,this._call].forEach(function(e){e&&e.eventNames().forEach(function(t){return e.removeAllListeners(t)})})},t.prototype._setupCallHandlers=function(e){var n=this;this._options.fakeMicInput&&e.once("volume",function(){e._mediaHandler.outputs.forEach(function(e){return e.audio.muted=!0})}),e.on("warning",function(e,t){n._emitWarning(e,"Received an RTCWarning. See .rtcWarning for the RTCWarning",t)}),e.once("accept",function(){n._callSid=e._mediaHandler.callSid,n._status=t.Status.Connected,n._log.debug("#"+t.Events.Connected),n.emit(t.Events.Connected)}),e.on("sample",function(r){return d(n,void 0,void 0,function(){var n;return l(this,function(i){switch(i.label){case 0:if(this._latestSample)return[3,2];return n=this,[4,(this._options.getRTCIceCandidateStatsReport||v.getRTCIceCandidateStatsReport)(e._mediaHandler.version.pc)];case 1:n._rtcIceCandidateStatsReport=i.sent(),i.label=2;case 2:return this._latestSample=r,this._samples.push(r),this._log.debug("#"+t.Events.Sample,JSON.stringify(r)),this.emit(t.Events.Sample,r),[2]}})})}),[{reportLabel:"peerConnection",type:"pcconnection"},{reportLabel:"ice",type:"iceconnection"},{reportLabel:"dtls",type:"dtlstransport"},{reportLabel:"signaling",type:"signaling"}].forEach(function(t){var r=t.type,i=t.reportLabel,o="on"+r+"statechange",a=e._mediaHandler[o];e._mediaHandler[o]=function(e){var t=n._networkTiming[i]=n._networkTiming[i]||{start:0};"connecting"===e||"checking"===e?t.start=Date.now():"connected"!==e&&"stable"!==e||t.duration||(t.end=Date.now(),t.duration=t.end-t.start),a(e)}})},Object.defineProperty(t.prototype,"callSid",{get:function(){return this._callSid},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endTime",{get:function(){return this._endTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"latestSample",{get:function(){return this._latestSample},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"report",{get:function(){return this._report},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startTime",{get:function(){return this._startTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this._status},enumerable:!1,configurable:!0}),t}(p.EventEmitter);t.PreflightTest=y,(o=(i=y=t.PreflightTest||(t.PreflightTest={})).CallQuality||(i.CallQuality={})).Excellent="excellent",o.Great="great",o.Good="good",o.Fair="fair",o.Degraded="degraded",(a=i.Events||(i.Events={})).Completed="completed",a.Connected="connected",a.Failed="failed",a.Sample="sample",a.Warning="warning",(s=i.Status||(i.Status={})).Connecting="connecting",s.Connected="connected",s.Completed="completed",s.Failed="failed",t.PreflightTest=y},47397:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(55445),a=n(6501),s=n(12861),c=n(92764),u=n(25889),d=function(e){function t(n,r,i){var o=e.call(this)||this;if(!(o instanceof t))return new t(n,r,i);var a={TransportFactory:u.default};for(var s in i=i||{},a)s in i||(i[s]=a[s]);return o.options=i,o.token=n||"",o.status="disconnected",o.gateway=null,o.region=null,o._messageQueue=[],o._preferredUri=null,o._uris=r,o._handleTransportClose=o._handleTransportClose.bind(o),o._handleTransportError=o._handleTransportError.bind(o),o._handleTrans
1portMessage=o._handleTransportMessage.bind(o),o._handleTransportOpen=o._handleTransportOpen.bind(o),o._log=new c.default("PStream"),o.on("error",function(){o._log.warn("Unexpected error handled in pstream")}),o.addListener("ready",function(){o.status="ready"}),o.addListener("offline",function(){o.status="offline"}),o.addListener("close",function(){o._log.info('Received "close" from server. Destroying PStream...'),o._destroy()}),o.transport=new o.options.TransportFactory(o._uris,{backoffMaxMs:o.options.backoffMaxMs,maxPreferredDurationMs:o.options.maxPreferredDurationMs}),Object.defineProperties(o,{uri:{enumerable:!0,get:function(){return this.transport.uri}}}),o.transport.on("close",o._handleTransportClose),o.transport.on("error",o._handleTransportError),o.transport.on("message",o._handleTransportMessage),o.transport.on("open",o._handleTransportOpen),o.transport.open(),o}return i(t,e),t}(o.EventEmitter);d.prototype._handleTransportClose=function(){this.emit("transportClose"),"disconnected"!==this.status&&("offline"!==this.status&&this.emit("offline",this),this.status="disconnected")},d.prototype._handleTransportError=function(e){if(!e){this.emit("error",{error:{code:31e3,message:"Websocket closed without a provided reason",twilioError:new s.SignalingErrors.ConnectionDisconnected}});return}this.emit("error",void 0!==e.code?{error:e}:e)},d.prototype._handleTransportMessage=function(e){if(e&&e.data&&"string"==typeof e.data){var t=JSON.parse(e.data),n=t.type,r=t.payload,i=void 0===r?{}:r;this.gateway=i.gateway||this.gateway,this.region=i.region||this.region,"error"===n&&i.error&&(i.error.twilioError=new s.SignalingErrors.ConnectionError),this.emit(n,i)}},d.prototype._handleTransportOpen=function(){var e=this;this.status="connected",this.setToken(this.token),this.emit("transportOpen"),this._messageQueue.splice(0,this._messageQueue.length).forEach(function(t){return e._publish.apply(e,t)})},d.toString=function(){return"[Twilio.PStream class]"},d.prototype.toString=function(){return"[Twilio.PStream instance]"},d.prototype.setToken=function(e){this._log.info("Setting token and publishing listen"),this.token=e;var t,n=0,r=this.options.maxPreferredDurationMs;this._log.info("maxPreferredDurationMs:"+r),"number"==typeof r&&r>=0&&(n=Math.min(Math.ceil(r/1e3),30)),this._log.info("reconnectTimeout:"+n);var i={browserinfo:{browser:{platform:(t="undefined"!=typeof navigator?navigator:{}).platform||"unknown",userAgent:t.userAgent||"unknown"},p:"browser",plugin:"rtc",v:a.RELEASE_VERSION},reconnectTimeout:n,token:e};this._publish("listen",i)},d.prototype.sendMessage=function(e,t,n,r,i){void 0===n&&(n="application/json");var o={callsid:e,content:t,contenttype:n,messagetype:r,voiceeventsid:i};this._publish("message",o,!0)},d.prototype.register=function(e){this._publish("register",{media:e},!0)},d.prototype.invite=function(e,t,n){this._publish("invite",{callsid:t,sdp:e,twilio:n?{params:n}:{}},!0)},d.prototype.reconnect=function(e,t,n){this._publish("invite",{callsid:t,reconnect:n,sdp:e,twilio:{}},!0)},d.prototype.answer=function(e,t){this._publish("answer",{sdp:e,callsid:t},!0)},d.prototype.dtmf=function(e,t){this._publish("dtmf",{callsid:e,dtmf:t},!0)},d.prototype.hangup=function(e,t){this._publish("hangup",t?{callsid:e,message:t}:{callsid:e},!0)},d.prototype.reject=function(e){this._publish("reject",{callsid:e},!0)},d.prototype.reinvite=function(e,t){this._publish("reinvite",{sdp:e,callsid:t},!1)},d.prototype._destroy=function(){this.transport.removeListener("close",this._handleTransportClose),this.transport.removeListener("error",this._handleTransportError),this.transport.removeListener("message",this._handleTransportMessage),this.transport.removeListener("open",this._handleTransportOpen),this.transport.close(),this.emit("offline",this)},d.prototype.destroy=function(){return this._log.info("PStream.destroy() called..."),this._destroy(),this},d.prototype.updatePreferredURI=function(e){this._preferredUri=e,this.transport.updatePreferredURI(e)},d.prototype.updateURIs=function(e){this._uris=e,this.transport.updateURIs(this._uris)},d.prototype.publish=function(e,t){return this._publish(e,t,!0)},d.prototype._publish=function(e,t,n){var r=JSON.stringify({payload:t,type:e,version:"1.6"});
1!this.transport.send(r)&&(this.emit("error",{error:{code:31009,message:"No transport available to send or receive messages",twilioError:new s.GeneralErrors.TransportError}}),n&&this._messageQueue.push([e,t,!0]))},t.default=d},29767:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRegionShortcode=t.getChunderURIs=t.createSignalingEndpointURL=t.createEventGatewayURI=t.defaultEdge=t.regionToEdge=t.regionShortcodes=t.Region=t.Edge=void 0;var r,i,o,a,s,c=n(12861);function u(e){return"voice-js."+e+".twilio.com"}(r=a=t.Edge||(t.Edge={})).Sydney="sydney",r.SaoPaulo="sao-paulo",r.Dublin="dublin",r.Frankfurt="frankfurt",r.Tokyo="tokyo",r.Singapore="singapore",r.Ashburn="ashburn",r.Umatilla="umatilla",r.Roaming="roaming",r.AshburnIx="ashburn-ix",r.SanJoseIx="san-jose-ix",r.LondonIx="london-ix",r.FrankfurtIx="frankfurt-ix",r.SingaporeIx="singapore-ix",r.SydneyIx="sydney-ix",r.TokyoIx="tokyo-ix",(i=s=t.Region||(t.Region={})).Au1="au1",i.Au1Ix="au1-ix",i.Br1="br1",i.De1="de1",i.De1Ix="de1-ix",i.Gll="gll",i.Ie1="ie1",i.Ie1Ix="ie1-ix",i.Ie1Tnx="ie1-tnx",i.Jp1="jp1",i.Jp1Ix="jp1-ix",i.Sg1="sg1",i.Sg1Ix="sg1-ix",i.Sg1Tnx="sg1-tnx",i.Us1="us1",i.Us1Ix="us1-ix",i.Us1Tnx="us1-tnx",i.Us2="us2",i.Us2Ix="us2-ix",i.Us2Tnx="us2-tnx",t.regionShortcodes={ASIAPAC_SINGAPORE:s.Sg1,ASIAPAC_SYDNEY:s.Au1,ASIAPAC_TOKYO:s.Jp1,EU_FRANKFURT:s.De1,EU_IRELAND:s.Ie1,SOUTH_AMERICA_SAO_PAULO:s.Br1,US_EAST_VIRGINIA:s.Us1,US_WEST_OREGON:s.Us2},t.regionToEdge=((o={})[s.Au1]=a.Sydney,o[s.Br1]=a.SaoPaulo,o[s.Ie1]=a.Dublin,o[s.De1]=a.Frankfurt,o[s.Jp1]=a.Tokyo,o[s.Sg1]=a.Singapore,o[s.Us1]=a.Ashburn,o[s.Us2]=a.Umatilla,o[s.Gll]=a.Roaming,o[s.Us1Ix]=a.AshburnIx,o[s.Us2Ix]=a.SanJoseIx,o[s.Ie1Ix]=a.LondonIx,o[s.De1Ix]=a.FrankfurtIx,o[s.Sg1Ix]=a.SingaporeIx,o[s.Au1Ix]=a.SydneyIx,o[s.Jp1Ix]=a.TokyoIx,o[s.Us1Tnx]=a.AshburnIx,o[s.Us2Tnx]=a.AshburnIx,o[s.Ie1Tnx]=a.LondonIx,o[s.Sg1Tnx]=a.SingaporeIx,o),t.defaultEdge=a.Roaming,t.createEventGatewayURI=function(e){return e?"eventgw."+e+".twilio.com":"eventgw.twilio.com"},t.createSignalingEndpointURL=function(e){return"wss://"+e+"/signal"},t.getChunderURIs=function(e){if(e&&"string"!=typeof e&&!Array.isArray(e))throw new c.InvalidArgumentError("If `edge` is provided, it must be of type `string` or an array of strings.");if(e){var n;n=(Array.isArray(e)?e:[e]).map(function(e){return u(e)})}else n=[u(t.defaultEdge)];return n},t.getRegionShortcode=function(e){return t.regionShortcodes[e]||null}},24400:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t,n){var r=JSON.stringify(t.body||{}),i=new Headers;t.headers=t.headers||[],Object.entries(t.headers).forEach(function(e){var t=e[0],n=e[1];return i.append(t,n)}),fetch(t.url,{body:r,headers:i,method:e}).then(function(e){return e.text()},n).then(function(e){return n(null,e)},n)};n.get=function(e,t){return new this("GET",e,t)},n.post=function(e,t){return new this("POST",e,t)},t.default=n},27491:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(12861),i=n(41262);t.default=function(e,t){return(t=t||{}).util=t.util||i,t.navigator=t.navigator||("undefined"!=typeof navigator?navigator:null),new Promise(function(n,i){if(!t.navigator)throw new r.NotSupportedError("getUserMedia is not supported");switch("function"){case typeof(t.navigator.mediaDevices&&t.navigator.mediaDevices.getUserMedia):return n(t.navigator.mediaDevices.getUserMedia(e));case typeof t.navigator.webkitGetUserMedia:return t.navigator.webkitGetUserMedia(e,n,i);case typeof t.navigator.mozGetUserMedia:return t.navigator.mozGetUserMedia(e,n,i);case typeof t.navigator.getUserMedia:return t.navigator.getUserMedia(e,n,i);default:throw new r.NotSupportedError("getUserMedia is not supported")}}).catch(function(e){throw t.util.isFirefox()&&"NotReadableError"===e.name?new r.NotSupportedError("Firefox does not currently support opening multiple audio input trackssimultaneously, even across different tabs.\nRelated Bugzilla thread: https://bugzilla.mozilla.org/show_bug.cgi?id=1299324"):e})}},64597:function(e,t){"use strict";
1Object.defineProperty(t,"__esModule",{value:!0}),t.IceCandidate=void 0;var n=function(){function e(e,t){void 0===t&&(t=!1),this.deleted=!1;var n,r=e.candidate.split("network-cost ");r[1]&&(n=parseInt(r[1],10)),this.candidateType=e.type,this.ip=e.ip||e.address,this.isRemote=t,this.networkCost=n,this.port=e.port,this.priority=e.priority,this.protocol=e.protocol,this.relatedAddress=e.relatedAddress,this.relatedPort=e.relatedPort,this.tcpType=e.tcpType,this.transportId=e.sdpMid}return e.prototype.toPayload=function(){return{candidate_type:this.candidateType,deleted:this.deleted,ip:this.ip,is_remote:this.isRemote,"network-cost":this.networkCost,port:this.port,priority:this.priority,protocol:this.protocol,related_address:this.relatedAddress,related_port:this.relatedPort,tcp_type:this.tcpType,transport_id:this.transportId}},e}();t.IceCandidate=n},88754:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PeerConnection=t.getMediaEngine=t.enabled=void 0;var r=n(42881);t.PeerConnection=r.default;var i=n(79134);t.enabled=function(){return i.default.test()},t.getMediaEngine=function(){return"undefined"!=typeof RTCIceGatherer?"ORTC":"WebRTC"}},79671:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="undefined"!=typeof window?window.RTCStatsReport:void 0;function r(e){if(!(this instanceof r))return new r(e);var t=this;Object.defineProperties(this,{_map:{value:e},size:{enumerable:!0,get:function(){return t._map.size}}}),this[Symbol.iterator]=e[Symbol.iterator]}function i(e){return{bytesReceived:void 0,bytesSent:void 0,dtlsState:void 0,id:e.id,localCertificateId:e.stat("localCertificateId"),remoteCertificateId:e.stat("remoteCertificateId"),rtcpTransportStatsId:void 0,selectedCandidatePairId:e.stat("selectedCandidatePairId"),timestamp:Date.parse(e.timestamp),type:"transport"}}function o(e,t){return{associateStatsId:void 0,codecId:"codec-"+e.id,firCount:t?c(e,"googFirsSent"):void 0,id:e.id,isRemote:void 0,mediaType:e.stat("mediaType"),nackCount:t?c(e,"googNacksSent"):c(e,"googNacksReceived"),pliCount:t?c(e,"googPlisSent"):c(e,"googPlisReceived"),qpSum:c(e,"qpSum"),sliCount:void 0,ssrc:e.stat("ssrc"),timestamp:Date.parse(e.timestamp),trackId:"track-"+e.id,transportId:e.stat("transportId")}}function a(e,t){return{candidateType:function(e){switch(e){case"peerreflexive":return"prflx";case"serverreflexive":return"srflx";default:return e}}(e.stat("candidateType")),deleted:void 0,id:e.id,ip:e.stat("ipAddress"),isRemote:t,port:c(e,"portNumber"),priority:u(e,"priority"),protocol:e.stat("transport"),relayProtocol:void 0,timestamp:Date.parse(e.timestamp),transportId:void 0,type:t?"remote-candidate":"local-candidate",url:void 0}}function s(e){return isNaN(e)||""===e?void 0:parseInt(e,10)/1e3}function c(e,t){var n=e.stat(t);return l(e,t)?parseInt(n,10):void 0}function u(e,t){var n=e.stat(t);return l(e,t)?parseFloat(n):void 0}function d(e,t){var n=e.stat(t);return l(e,t)?"true"===n||!0===n:void 0}function l(e,t){var n=e.stat(t);return void 0!==n&&""!==n}n&&(r.prototype=Object.create(n.prototype),r.prototype.constructor=r),["entries","forEach","get","has","keys","values"].forEach(function(e){r.prototype[e]=function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return(t=this._map)[e].apply(t,n)}}),r.fromArray=function(e){return new r(e.reduce(function(e,t){return e.set(t.id,t),e},new Map))},r.fromRTCStatsResponse=function(e){var t,n=new Map,p=e.result().reduce(function(e,r){var p,f,h=r.id;switch(r.type){case"googCertificate":e.set(h,{base64Certificate:r.stat("googDerBase64"),fingerprint:r.stat("googFingerprint"),fingerprintAlgorithm:r.stat("googFingerprintAlgorithm"),id:r.id,issuerCertificateId:r.stat("googIssuerId"),timestamp:Date.parse(r.timestamp),type:"certificate"});break;case"datachannel":e.set(h,{bytesReceived:void 0,bytesSent:void 0,datachannelid:r.stat("datachannelid"),id:r.id,label:r.stat("label"),messagesReceived:void 0,messagesSent:void 0,protocol:r.stat("protocol"),state:r.stat("state"),timestamp:Date.parse(r.timestamp),transportId:r.stat("transportId"),type:"data-channel"});break;case"googCandidatePair":d(r,"googActiveConnection")&&(t=h),e.set(h,{availableIncomingBitrate:void 0,availableOutgoingBitrate:void 0,bytesReceived:c(r,"bytesReceived"),bytesSent:c(r,"bytesSent"),consentRequestsSent:c(r,"consentRequestsSent"),currentRoundTripTime:s(r.stat("googRtt")),id:r.id,lastPacketReceivedTimestamp:void 0,lastPacketSentTimestamp:void 0,localCandidateId:r.stat("localCandidateId"),nominated:void 0,priority:void 0,readable:void 0,remoteCandidateId:r.stat("remoteCandidateId"),requestsReceived:c(r,"requestsReceived"),requestsSent:c(r,"requestsSent"),responsesReceived:c(r,"responsesReceived"),responsesSent:c(r,"responsesSent"),retransmissionsReceived:void 0,retransmissionsSent:void 0,state:void 0,timestamp:Date.parse(r.t
1imestamp),totalRoundTripTime:void 0,transportId:r.stat("googChannelId"),type:"candidate-pair",writable:d(r,"googWritable")});break;case"localcandidate":e.set(h,a(r,!1));break;case"remotecandidate":e.set(h,a(r,!0));break;case"ssrc":l(r,"packetsReceived")?e.set("rtp-"+h,(Object.assign(p=o(r,!0),{burstDiscardCount:void 0,burstDiscardRate:void 0,burstLossCount:void 0,burstLossRate:void 0,burstPacketsDiscarded:void 0,burstPacketsLost:void 0,bytesReceived:c(r,"bytesReceived"),fractionLost:void 0,framesDecoded:c(r,"framesDecoded"),gapDiscardRate:void 0,gapLossRate:void 0,jitter:s(r.stat("googJitterReceived")),packetsDiscarded:void 0,packetsLost:c(r,"packetsLost"),packetsReceived:c(r,"packetsReceived"),packetsRepaired:void 0,roundTripTime:s(r.stat("googRtt")),type:"inbound-rtp"}),p)):e.set("rtp-"+h,(Object.assign(f=o(r,!1),{bytesSent:c(r,"bytesSent"),framesEncoded:c(r,"framesEncoded"),packetsSent:c(r,"packetsSent"),remoteTimestamp:void 0,targetBitrate:void 0,type:"outbound-rtp"}),f)),e.set("track-"+h,{audioLevel:l(r,"audioOutputLevel")?c(r,"audioOutputLevel")/32767:(c(r,"audioInputLevel")||0)/32767,detached:void 0,echoReturnLoss:u(r,"googEchoCancellationReturnLoss"),echoReturnLossEnhancement:u(r,"googEchoCancellationReturnLossEnhancement"),ended:void 0,frameHeight:l(r,"googFrameHeightReceived")?c(r,"googFrameHeightReceived"):c(r,"googFrameHeightSent"),frameWidth:l(r,"googFrameWidthReceived")?c(r,"googFrameWidthReceived"):c(r,"googFrameWidthSent"),framesCorrupted:void 0,framesDecoded:c(r,"framesDecoded"),framesDropped:void 0,framesPerSecond:void 0,framesReceived:void 0,framesSent:c(r,"framesEncoded"),fullFramesLost:void 0,id:r.id,kind:r.stat("mediaType"),partialFramesLost:void 0,remoteSource:void 0,ssr
1cIds:void 0,timestamp:Date.parse(r.timestamp),trackIdentifier:r.stat("googTrackId"),type:"track"}),e.set("codec-"+h,{channels:void 0,clockRate:void 0,id:r.id,implementation:void 0,mimeType:r.stat("mediaType")+"/"+r.stat("googCodecName"),payloadType:void 0,sdpFmtpLine:void 0,timestamp:Date.parse(r.timestamp),type:"codec"});break;case"googComponent":var m=i(r);n.set(m.selectedCandidatePairId,h),e.set(h,i(r))}return e},new Map);if(t){var f=n.get(t);f&&(p.get(f).dtlsState="connected")}return new r(p)},t.default=r},82413:function(e,t){"use strict";function n(e,t,n){if("number"!=typeof e||"number"!=typeof t||"number"!=typeof n||!r(e)||!r(t)||!r(n))return null;var i=e+2*t+10,o=0;switch(!0){case i<160:o=94.768-i/40;break;case i<1e3:o=94.768-(i-120)/10}return 1+.035*(o=!0==n<=o/2.5?Math.max(o-2.5*n,6.52):0)+7e-6*o*(o-60)*(100-o)}function r(e){return"number"==typeof e&&!isNaN(e)&&isFinite(e)&&e>=0}Object.defineProperty(t,"__esModule",{value:!0}),t.isNonNegativeNumber=t.calculate=void 0,t.calculate=n,t.isNonNegativeNumber=r,t.default={calculate:n,isNonNegativeNumber:r}},42881:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(12861),i=n(92764),o=n(41262),a=n(79134),s=n(72779);function c(e,t,n){if(!e||!t)throw new r.InvalidArgumentError("Audiohelper, and pstream are required arguments");if(!(this instanceof c))return new c(e,t,n);function a(){this._log.warn("Unexpected noop call in peerconnection")}this._log=new i.default("PeerConnection"),this.onaudio=a,this.onopen=a,this.onerror=a,this.onclose=a,this.ondisconnected=a,this.onfailed=a,this.onconnected=a,this.onreconnected=a,this.onsignalingstatechange=a,this.ondtlstransportstatechange=a,this.onicegatheringfailure=a,this.onicegatheringstatechange=a,this.oniceconnectionstatechange=a,this.onpcconnectionstatechange=a,this.onicecandidate=a,this.onselectedcandidatepairchange=a,this.onvolume=a,this.version=null,this.pstream=t,this.stream=null,this.sinkIds=new Set(["default"]),this.outputs=new Map,this.status="connecting",this.callSid=null,this.isMuted=!1;var s="undefined"!=typeof window&&(window.AudioContext||window.webkitAudioContext);return this._isSinkSupported=!!s&&"undefined"!=typeof HTMLAudioElement&&HTMLAudioElement.prototype.setSinkId,this._audioContext=s&&e._audioContext,this._audioHelper=e,this._hasIceCandidates=!1,this._hasIceGatheringFailures=!1,this._iceGatheringTimeoutId=null,this._masterAudio=null,this._masterAudioDeviceId=null,this._mediaStreamSource=null,this._dtmfSender=null,this._dtmfSenderUnsupported=!1,this._callEvents=[],this._nextTimeToPublish=Date.now(),this._onAnswerOrRinging=a,this._onHangup=a,this._remoteStream=null,this._shouldManageStream=!0,this._iceState="new",this._isUnifiedPlan=n.isUnifiedPlan,this.options=n=n||{},this.navigator=n.navigator||("undefined"!=typeof navigator?navigator:null),this.util=n.util||o,this.codecPreferences=n.codecPreferences,this}function u(e,t){"function"==typeof e.addTrack?t.getAudioTracks().forEach(function(n){e.addTrack(n,t)}):e.addStream(t)}function d(e){var t="undefined"!=typeof MediaStream?new MediaStream:new webkitMediaStream;return e.getAudioTracks().forEach(t.addTrack,t),t}function l(e,t){if(void 0!==e.srcObject)e.srcObject=t;else if(void 0!==e.mozSrcObject)e.mozSrcObject=t;else{if(void 0===e.src)return!1;var n=e.options.window||window;e.src=(n.URL||n.webkitURL).createObjectURL(t)}return!0}c.prototype.uri=function(){return this._uri},c.prototype.openDefaultDeviceWithConstraints=function(e){return this._audioHelper._openDefaultDeviceWithConstraints(e).then(this._setInputTracksFromStream.bind(this,!1))},c.prototype.setInputTracksFromStream=function(e){var t=this;return this._setInputTracksFromStream(!0,e).then(function(){t._shouldManageStream=!1})},c.prototype._createAnalyser=function(e,t){t=Object.assign({fftSize:32,smoothingTimeConstant:.3},t);var n=e.createAnalyser();for(var r in t)n[r]=t[r];return n},c.prototype._setVolumeHandler=function(e){this.onvolume=e},c.prototype._startPollingVolume=function(){if(this._audioContext&&this.stream&&this._remoteStream){var e=this._audioContext,t=new Uint8Array((this._inputAnalyser=this._createAnalyser(e)).frequencyBinCount);this._inputAnalyser2=this._createAnalyser(e,{maxDecibels:0,minDecibels:-127,smoothingTimeConstant:0});var n=new Uint8Array((this._outputAnalyser=this._createAnalyser(e)).frequencyBinCount);this._outputAnalyser2=this._createAnalyser(e,{maxDecibels:0,minDecibels:-127,smoothingTimeConstant:0}),this._updateInputStreamSource(this.stream),this._updateOutputStreamSource(this._remoteStream);var r=this;setTimeout(function e(){if(r._audioContext){if("closed"===r.status){r._inputAnalyser.disconnect(),r._outputAnalyser.disconnect(),r._inputAnalyser2.disconnect(),r._outputAnalyser2.disconnect();return}r._inputAnalyser.getByteFrequencyData(t);var i=r.util.average(t);r._inputAnalyser2.getByteFrequencyData(t);var o=r.util.average(t);r._outputAnalyser.getByteFrequencyData(n);var a=r.util.average(n);r._outputAnalyser2.getByteFrequencyData(n);var s=r.util.average(n);r.onvolume(i/255,a/255,o,s),setTimeout(e,50)}},50)}},c.prototype._stopStream=function(){this._shouldManageStream&&this._audioHelper._stopDefaultInputDeviceStream()},c.prototype._updateInputStreamSource=function(e){this._inputStreamSource&&this._inputStreamSource.disconnect();try{this._inputStreamSource=this._audioContext.createMediaStreamSource(e),this._inputStreamSource.connect(this._inputAnalyser),this._inputStreamSource.connect(this._inputAnalyser2)}catch(e){this._log.warn("Unable to update input MediaStreamSource",e),this._inputStreamSource=null}},c.prototype._updateOutputStreamSource=function(e){this._outputStreamSource&&this._outputStreamSource.disconnect();try{this._outputStreamSource=this._audioContext.createMediaStreamSource(e),this._outputStreamSource.connect(this._outputAnalyser),this._outputStreamSource.connect(this._outputAnalyser2)}catch(e){this._log.warn("Unable to update output MediaStreamSource",e),this._outputStreamSource=null}},c.prototype._setInputTracksFromStream=function(e,t){return this._isUnifiedPlan?this._setInputTracksForUnifiedPlan(e,t):this._setInputTracksForPlanB(e,t)},c.prototype._setInputTracksForPlanB=function(e,t){var n,i=this;if(!t)return Promise.reject(new r.InvalidArgumentError("Can not set input stream to null while in a call"));if(!t.getAudioTracks().length)return Promise.reject(new r.InvalidArgumentError("Supplied input stream has no audio tracks"));var o=this.stream;return(o?(this._stopStream(),"function"==typeof(n=this.version.pc).removeTrack?n.getSenders().forEac
1h(function(e){n.removeTrack(e)}):n.removeStream(o),o.getAudioTracks().forEach(o.removeTrack,o),t.getAudioTracks().forEach(o.addTrack,o),u(this.version.pc,t),this._updateInputStreamSource(this.stream)):this.stream=e?d(t):t,this.mute(this.isMuted),this.version)?new Promise(function(e,t){i.version.createOffer(i.options.maxAverageBitrate,i.codecPreferences,{audio:!0},function(){i.version.processAnswer(i.codecPreferences,i._answerSdp,function(){e(i.stream)},t)},t)}):Promise.resolve(this.stream)},c.prototype._setInputTracksForUnifiedPlan=function(e,t){var n=this;if(!t)return Promise.reject(new r.InvalidArgumentError("Can not set input stream to null while in a call"));if(!t.getAudioTracks().length)return Promise.reject(new r.InvalidArgumentError("Supplied input stream has no audio tracks"));var i=this.stream,o=function(){return n.mute(n.isMuted),Promise.resolve(n.stream)};return i?(this._shouldManageStream&&this._stopStream(),this._sender||(this._sender=this.version.pc.getSenders()[0]),this._sender.replaceTrack(t.getAudioTracks()[0]).then(function(){return n._updateInputStreamSource(t),n.stream=e?d(t):t,o()})):(this.stream=e?d(t):t,o())},c.prototype._onInputDevicesChanged=function(){this.stream&&this.stream.getAudioTracks().every(function(e){return"ended"===e.readyState})&&this._shouldManageStream&&this.openDefaultDeviceWithConstraints({audio:!0})},c.prototype._onIceGatheringFailure=function(e){this._hasIceGatheringFailures=!0,this.onicegatheringfailure(e)},c.prototype._onMediaConnectionStateChange=function(e){var t,n=this._iceState;if(n!==e&&("connected"===e||"disconnected"===e||"failed"===e))switch(this._iceState=e,e){case"connected":"disconnected"===n||"failed"===n?(t="ICE liveliness check succeeded. Connection with Twilio restored",this._log.info(t),this.onreconnected(t)):(t="Media connection established.",this._log.info(t),this.onconnected(t)),this._stopIceGatheringTimeout(),this._hasIceGatheringFailures=!1;break;case"disconnected":t="ICE liveliness check failed. May be having trouble connecting to Twilio",this._log.warn(t),this.ondisconnected(t);break;case"failed":t="Connection with Twilio was interrupted.",this._log.warn(t),this.onfailed(t)}},c.prototype._setSinkIds=function(e){return this._isSinkSupported?(this.sinkIds=new Set(e.forEach?e:[e]),this.version?this._updateAudioOutputs():Promise.resolve()):Promise.reject(new r.NotSupportedError("Audio output selection is not supported by this browser"))},c.prototype._startIceGatheringTimeout=function(){var e=this;this._stopIceGatheringTimeout(),this._iceGatheringTimeoutId=setTimeout(function(){e._onIceGatheringFailure("timeout")},15e3)},c.prototype._stopIceGatheringTimeout=function(){clearInterval(this._iceGatheringTimeoutId)},c.prototype._updateAudioOutputs=function(){var e=Array.from(this.sinkIds).filter(function(e){return!this.outputs.has(e)},this),t=Array.from(this.outputs.keys()).filter(function(e){return!this.sinkIds.has(e)},this),n=this;return Promise.all(e.map(this._createAudioOutput,this)).then(function(){return Promise.all(t.map(n._removeAudioOutput,n))})},c.prototype._createAudio=function(e){var t=new Audio(e);return this.onaudio(t),t},c.prototype._createAudioOutput=function(e){var t=null;this._mediaStreamSource&&(t=this._audioContext.createMediaStreamDestination(),this._mediaStreamSource.connect(t));var n=this._createAudio();l(n,t&&t.stream?t.stream:this.pcStream);var r=this;return n.setSinkId(e).then(function(){return n.play()}).then(function(){r.outputs.set(e,{audio:n,dest:t})})},c.prototype._removeAudioOutputs=function(){return this._masterAudio&&void 0!==this._masterAudioDeviceId&&(this._disableOutput(this,this._masterAudioDeviceId),this.outputs.delete(this._masterAudioDeviceId),this._masterAudioDeviceId=null,this._masterAudio.paused||this._masterAudio.pause(),void 0!==this._masterAudio.srcObject?this._masterAudio.srcObject=null:this._masterAudio.src="",this._masterAudio=null),Array.from(this.outputs.keys()).map(this._removeAudioOutput,this)},c.prototype._disableOutput=function(e,t){var n=e.outputs.get(t);n&&(n.audio&&(n.audio.pause(),n.audio.src=""),n.dest&&n.dest.disconnect())},c.prototype._reassignMasterOutput=function(e,t){var n=e.outputs.get(t);e.outputs.delete(t);var r=this,i=Array.from(e.outputs.keys())[0],o="string"==typeof i?i:"default";return n.audio.setSinkId(o).then(function(){r._disableOutput(e,o),e.outputs.set(o,n),e._masterAudioDeviceId=o}).catch(function(){e.outputs.set(t,n),r._log.info("Could not reassign master output. Attempted to roll back.")})},c.prototype._removeAudioOutput=function(e){return this._masterAudioDeviceId===e?this._reassignMasterOutput(this,e):(this._disableOutput(this,e),this.outputs.delete(e),Promise.resolve())},c.prototype._onAddTrack=function(e,t){var n=e._masterAudio=this._createAudio();l(n,t),n.play();var r=Array.from(e.outputs.keys())[0],i="string"==typeof r?r:"default";e._masterAudioDeviceId=i,e.outputs.set(i,{audio:n});try{e._mediaStreamSource=e._audioContext.createMediaStreamSource(t)}catch(e){this._log.warn("Unable to create a MediaStreamSource from onAddTrack",e),this._mediaStreamSource=null}e.pcStream=t,e._updateAudioOutputs()},c.prototype._fallbackOnAddTrack=function(e,t){var n=document&&document.createElement("audio");n.autoplay=!0,l(n,t)||e._log.info("Error attaching stream to element."),e.outputs.set("default",{audio:n})},c.prototype._setEncodingParameters=function(e){if(e&&this._sender&&"function"==typeof this._sender.getParameters&&"function"==typeof this._sender.setParameters){var t=this._sender.getParameters();(t.priority||t.encodings&&t.encodings.length)&&(t.priority="high",t.encodings&&t.encodings.length&&t.encodings.forEac
1h(function(e){e.priority="high",e.networkPriority="high"}),this._sender.setParameters(t))}},c.prototype._setupPeerConnection=function(e){var t=this,n=this,r=new(this.options.rtcpcFactory||a.default)({RTCPeerConnection:this.options.RTCPeerConnection});r.create(e),u(r.pc,this.stream);var i="ontrack"in r.pc?"ontrack":"onaddstream";return r.pc[i]=function(e){var i=n._remoteStream=e.stream||e.streams[0];"function"==typeof r.pc.getSenders&&(t._sender=r.pc.getSenders()[0]),n._isSinkSupported?n._onAddTrack(n,i):n._fallbackOnAddTrack(n,i),n._startPollingVolume()},r},c.prototype._maybeSetIceAggressiveNomination=function(e){return this.options.forceAggressiveIceNomination?s.setIceAggressiveNomination(e):e},c.prototype._setupChannel=function(){var e=this,t=this.version.pc;this.version.pc.onopen=function(){e.status="open",e.onopen()},this.version.pc.onstatechange=function(){e.version.pc&&"stable"===e.version.pc.readyState&&(e.status="open",e.onopen())},this.version.pc.onsignalingstatechange=function(){var n=t.signalingState;e._log.info('signalingState is "'+n+'"'),e.version.pc&&"stable"===e.version.pc.signalingState&&(e.status="open",e.onopen()),e.onsignalingstatechange(t.signalingState)},t.onconnectionstatechange=function(n){var r=t.connectionState;if(!r&&n&&n.target){var i=n.target;r=i.connectionState||i.connectionState_,e._log.info("pc.connectionState not detected. Using target PC. State="+r)}r?e._log.info('pc.connectionState is "'+r+'"'):e._log.warn('onconnectionstatechange detected but state is "'+r+'"'),e.onpcconnectionstatechange(r),e._onMediaConnectionStateChange(r)},t.onicecandidate=function(t){var n=t.candidate;n&&(e._hasIceCandidates=!0,e.onicecandidate(n),e._setupRTCIceTransportListener()),e._log.info("ICE Candidate: "+JSON.stringify(n))},t.onicegatheringstatechange=function(){var n=t.iceGatheringState;"gathering"===n?e._startIceGatheringTimeout():"complete"===n&&(e._stopIceGatheringTimeout(),e._hasIceCandidates||e._onIceGatheringFailure("none"),e._hasIceCandidates&&e._hasIceGatheringFailures&&e._startIceGatheringTimeout()),e._log.info('pc.iceGatheringState is "'+t.iceGatheringState+'"'),e.onicegatheringstatechange(n)},t.oniceconnectionstatechange=function(){e._log.info('pc.iceConnectionState is "'+t.iceConnectionState+'"'),e.oniceconnectionstatechange(t.iceConnectionState),e._onMediaConnectionStateChange(t.iceConnectionState)}},c.prototype._initializeMediaStream=function(e){return"open"!==this.status&&("disconnected"===this.pstream.status?(this.onerror
1({info:{code:31e3,message:"Cannot establish connection. Client is disconnected",twilioError:new r.SignalingErrors.ConnectionDisconnected}}),this.close(),!1):(this.version=this._setupPeerConnection(e),this._setupChannel(),!0))},c.prototype._removeReconnectionListeners=function(){this.pstream&&(this.pstream.removeListener("answer",this._onAnswerOrRinging),this.pstream.removeListener("hangup",this._onHangup))},c.prototype._setupRTCDtlsTransportListener=function(){var e=this,t=this.getRTCDtlsTransport();if(t&&!t.onstatechange){var n=function(){e._log.info('dtlsTransportState is "'+t.state+'"'),e.ondtlstransportstatechange(t.state)};n(),t.onstatechange=n}},c.prototype._setupRTCIceTransportListener=function(){var e=this,t=this._getRTCIceTransport();t&&!t.onselectedcandidatepairchange&&(t.onselectedcandidatepairchange=function(){return e.onselectedcandidatepairchange(t.getSelectedCandidatePair())})},c.prototype.iceRestart=function(){var e=this;this._log.info("Attempting to restart ICE..."),this._hasIceCandidates=!1,this.version.createOffer(this.options.maxAverageBitrate,this.codecPreferences,{iceRestart:!0}).then(function(){e._removeReconnectionListeners(),e._onAnswerOrRinging=function(t){if(e._removeReconnectionListeners(),!t.sdp||"have-local-offer"!==e.version.pc.signalingState){var n="Invalid state or param during ICE Restart:hasSdp:"+!!t.sdp+", signalingState:"+e.version.pc.signalingState;e._log.warn(n);return}var r=e._maybeSetIceAggressiveNomination(t.sdp);e._answerSdp=r,"closed"!==e.status&&e.version.processAnswer(e.codecPreferences,r,null,function(t){var n=t&&t.message?t.message:t;e._log.error("Failed to process answer during ICE Restart. Error: "+n)})},e._onHangup=function(){e._log.info("Received hangup during ICE Restart"),e._removeReconnectionListeners()},e.pstream.on("answer",e._onAnswerOrRinging),e.pstream.on("hangup",e._onHangup),e.pstream.reinvite(e.version.getSDP(),e.callSid)}).catch(function(t){var n=t&&t.message?t.message:t;e._log.error("Failed to createOffer during ICE Restart. Error: "+n),e.onfailed(n)})},c.prototype.makeOutgoingCall=function(e,t,n,i,o){var a=this;if(this._initializeMediaStream(i)){var s=this;this.callSid=n,this._onAnswerOrRinging=function(e){if(e.sdp){var t=a._maybeSetIceAggressiveNomination(e.sdp);s._answerSdp=t,"closed"!==s.status&&s.version.processAnswer(a.codecPreferences,t,c,u),s.pstream.removeListener("answer",s._onAnswerOrRinging),s.pstream.removeListener("ringing",s._onAnswerOrRinging)}},this.pstream.on("answer",this._onAnswerOrRinging),this.pstream.on("ringing",this._onAnswerOrRinging),this.version.createOffer(this.options.maxAverageBitrate,this.codecPreferences,{audio:!0},function(){"closed"!==s.status&&(t?s.pstream.reconnect(s.version.getSDP(),s.callSid,t):s.pstream.invite(s.version.getSDP(),s.callSid,e),s._setupRTCDtlsTransportListener())},function(e){var t=e.message||e;s.onerror({info:{code:31e3,message:"Error creating the offer: "+t,twilioError:new r.MediaErrors.ClientLocalDescFailed}})})}function c(){s.options&&s._setEncodingParameters(s.options.dscp),o(s.version.pc)}function u(e){var t=e.message||e;s.onerror({info:{code:31e3,message:"Error processing answer: "+t,twilioError:new r.MediaErrors.ClientRemoteDescFailed}})}},c.prototype.answerIncomingCall=function(e,t,n,i){if(this._initializeMediaStream(n)){t=this._maybeSetIceAggressiveNomination(t),this._answerSdp=t.replace(/^a=setup:actpass$/gm,"a=setup:passive"),this.callSid=e;var o=this;this.version.processSDP(this.options.maxAverageBitrate,this.codecPreferences,t,{audio:!0},function(){"closed"!==o.status&&(o.pstream.answer(o.version.getSDP(),e),o.options&&o._setEncodingParameters(o.options.dscp),i(o.version.pc),o._setupRTCDtlsTransportListener())},function(e){var t=e.message||e;o.onerror({info:{code:31e3,message:"Error creating the answer: "+t,twilioError:new r.MediaErrors.ClientRemoteDescFailed}})})}},c.prototype.close=function(){this.version&&this.version.pc&&("closed"!==this.version.pc.signalingState&&this.version.pc.close(),this.version.pc=null),this.stream&&(this.mute(!1),this._stopStream()),this.stream=null,this._removeReconnectionListeners(),this._stopIceGatheringTimeout(),Promise.all(this._removeAudioOutputs()).catch(function(){}),this._mediaStreamSource&&this._mediaStreamSource.disconnect(),this._inputAnalyser&&this._inputAnalyser.disconnect(),this._outputAnalyser&&this._outputAnalyser.disconnect(),this._inputAnalyser2&&this._inputAnalyser2.disconnect(),this._outputAnalyser2&&this._outputAnalyser2.disconnect(),this.status="closed",this.onclose()},c.prototype.reject=function(e){this.callSid=e},c.prototype.ignore=function(e){this.callSid=e},c.prototype.mute=function(e){this.isMuted=e,this.stream&&(this._sender&&this._sender.track?this._sender.track.enabled=!e:("function"==typeof this.stream.getAudioTracks?this.stream.getAudioTracks():this.stream.audioTracks).forEac
1h(function(t){t.enabled=!e}))},c.prototype.getOrCreateDTMFSender=function(){if(this._dtmfSender||this._dtmfSenderUnsupported)return this._dtmfSender||null;var e=this,t=this.version.pc;if(!t)return this._log.warn("No RTCPeerConnection available to call createDTMFSender on"),null;if("function"==typeof t.getSenders&&("function"==typeof RTCDTMFSender||"function"==typeof RTCDtmfSender)){var n=t.getSenders().find(function(e){return e.dtmf});if(n)return this._log.info("Using RTCRtpSender#dtmf"),this._dtmfSender=n.dtmf,this._dtmfSender}if("function"==typeof t.createDTMFSender&&"function"==typeof t.getLocalStreams){var r=t.getLocalStreams().map(function(t){var n=e._getAudioTracks(t);return n&&n[0]})[0];return r?(this._log.info("Creating RTCDTMFSender"),this._dtmfSender=t.createDTMFSender(r),this._dtmfSender):(this._log.warn("No local audio MediaStreamTrack available on the RTCPeerConnection to pass to createDTMFSender"),null)}return this._log.info("RTCPeerConnection does not support RTCDTMFSender"),this._dtmfSenderUnsupported=!0,null},c.prototype.getRTCDtlsTransport=function(){var e=this.version&&this.version.pc&&"function"==typeof this.version.pc.getSenders&&this.version.pc.getSenders()[0];return e&&e.transport||null},c.prototype._canStopMediaStreamTrack=function(){return"function"==typeof MediaStreamTrack.prototype.stop},c.prototype._getAudioTracks=function(e){return"function"==typeof e.getAudioTracks?e.getAudioTracks():e.audioTracks},c.prototype._getRTCIceTransport=function(){var e=this.getRTCDtlsTransport();return e&&e.iceTransport||null},c.protocol=a.default.test()?new a.default:null,c.enabled=a.default.test(),t.default=c},79134:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(92764),i=n(41262),o=n(72779),a=n(74421);function s(e){if("undefined"==typeof window){this.log.info("No RTCPeerConnection implementation available. The window object was not found.");return}e&&e.RTCPeerConnection?this.RTCPeerConnection=e.RTCPeerConnection:i.isLegacyEdge()?this.RTCPeerConnection=new a("undefined"!=typeof window?window:n.g):"function"==typeof window.RTCPeerConnection?this.RTCPeerConnection=window.RTCPeerConnection:"function"==typeof window.webkitRTCPeerConnection?this.RTCPeerConnection=webkitRTCPeerConnection:"function"==typeof window.mozRTCPeerConnection?(this.RTCPeerConnection=mozRTCPeerConnection,window.RTCSessionDescription=mozRTCSessionDescription,window.RTCIceCandidate=mozRTCIceCandidate):this.log.info("No RTCPeerConnection implementation available")}function c(e,t,n,r){return function(){var i=Array.prototype.slice.call(arguments);return new Promise(function(n){var o=e.apply(t,i);if(!r){n(o);return}if("object"==typeof o&&"function"==typeof o.then)n(o);else throw Error()}).catch(function(){return new Promise(function(r,o){e.apply(t,n?[r,o].concat(i):i.concat([r,o]))})})}}function u(e,t){return c(e,t,!1,!1)}s.prototype.create=function(e){this.log=new r.default("RTCPC"),this.pc=new this.RTCPeerConnection(e)},s.prototype.createModernConstraints=function(e){if(void 0===e)return null;var t=Object.assign({},e);return"undefined"==typeof webkitRTCPeerConnection||i.isLegacyEdge()?(void 0!==e.audio&&(t.offerToReceiveAudio=e.audio),void 0!==e.video&&(t.offerToReceiveVideo=e.video)):(t.mandatory={},void 0!==e.audio&&(t.mandatory.OfferToReceiveAudio=e.audio),void 0!==e.video&&(t.mandatory.OfferToReceiveVideo=e.video)),delete t.audio,delete t.video,t},s.prototype.createOffer=function(e,t,n,r,i){var a=this;return n=this.createModernConstraints(n),c(this.pc.createOffer,this.pc,!0,!0)(n).then(function(n){if(!a.pc)return Promise.resolve();var r=o.setMaxAverageBitrate(n.sdp,e);return u(a.pc.setLocalDescription,a.pc)(new RTCSessionDescription({sdp:o.setCodecPreferences(r,t),type:"offer"}))}).then(r,i)},s.prototype.createAnswer=function(e,t,n,r,i){var a=this;return n=this.createModernConstraints(n),c(this.pc.createAnswer,this.pc,!0,!0)(n).then(function(n){if(!a.pc)return Promise.resolve();var r=o.setMaxAverageBitrate(n.sdp,e);return u(a.pc.setLocalDescription,a.pc)(new RTCSessionDescription({sdp:o.setCodecPreferences(r,t),type:"answer"}))}).then(r,i)},s.prototype.processSDP=function(e,t,n,r,i,a){var s=this,c=new RTCSessionDescription({sdp:n=o.setCodecPreferences(n,t),type:"offer"});return u(this.pc.setRemoteDescription,this.pc)(c).then(function(){s.createAnswer(e,t,r,i,a)})},s.prototype.getSDP=function(){return this.pc.localDescription.sdp},s.prototype.processAnswer=function(e,t,n,r){return this.pc?(t=o.setCodecPreferences(t,e),u(this.pc.setRemoteDescription,this.pc)(new RTCSessionDescription({sdp:t,type:"answer"})).then(n,r)):Promise.resolve()},s.test=function(){if("object"==typeof navigator){var e=navigator.mediaDevices&&navigator.mediaDevices.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.getUserMedia;if(i.isLegacyEdge(navigator))return!1;if(e&&"function"==typeof window.RTCPeerConnection||e&&"function"==typeof window.webkitRTCPeerConnection)return!0;
1if(e&&"function"==typeof window.mozRTCPeerConnection){try{var t=new window.mozRTCPeerConnection;if("function"!=typeof t.getLocalStreams)return!1}catch(e){return!1}return!0}if("undefined"!=typeof RTCIceGatherer)return!0}return!1},t.default=s},72779:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setMaxAverageBitrate=t.setIceAggressiveNomination=t.setCodecPreferences=t.getPreferredCodecInfo=void 0;var r=n(41262),i={0:"PCMU",8:"PCMA"};t.getPreferredCodecInfo=function(e){var t=/a=rtpmap:(\d+) (\S+)/m.exec(e)||[null,"",""],n=t[1];return{codecName:t[2],codecParams:(RegExp("a=fmtp:"+n+" (\\S+)","m").exec(e)||[null,""])[1]}},t.setIceAggressiveNomination=function(e){return r.isChrome(window,window.navigator)?e.split("\n").filter(function(e){return -1===e.indexOf("a=ice-lite")}).join("\n"):e},t.setMaxAverageBitrate=function(e,t){if("number"!=typeof t||t<6e3||t>51e4)return e;var n=/a=rtpmap:(\d+) opus/m.exec(e),r=RegExp("a=fmtp:"+(n&&n.length?n[1]:111));return e.split("\n").map(function(e){return r.test(e)?e+";maxaveragebitrate="+t:e}).join("\n")},t.setCodecPreferences=function(e,t){var n=e.replace(/\r\n\r\n$/,"\r\n").split("\r\nm=").slice(1).map(function(e){return"m="+e}).filter(function(e){var t=RegExp("m=.*","gm"),n=RegExp("a=.*","gm");return t.test(e)&&n.test(e)});return[e.split("\r\nm=")[0]].concat(n.map(function(e){if(!/^m=(audio|video)/.test(e))return e;var n,o,a,s,c,u,d,l,p=e.match(/^m=(audio|video)/)[1],f=Array.from(((n=e.split("\r\n")[0].match(/([0-9]+)/g))?n.slice(1).map(function(e){return parseInt(e,10)}):[]).reduce(function(t,n){var r=RegExp("a=rtpmap:"+n+" ([^/]+)"),o=e.match(r),a=o?o[1].toLowerCase():i[n]?i[n].toLowerCase():"";return t.set(n,a)},new Map)).reduce(function(e,t){var n=t[0],r=t[1],i=e.get(r)||[];return e.set(r,i.concat(n))},new Map),h=(o=(o=t).map(function(e){return e.toLowerCase()}),a=r.flatMap(o,function(e){return f.get(e)||[]}),s=r.difference(Array.from(f.keys()),o),c=r.flatMap(s,function(e){return f.get(e)}),a.concat(c)),m=(d=(u=e.split("\r\n"))[0],l=u.slice(1),[d=d.replace(/([0-9]+\s?)+$/,h.join(" "))].concat(l).join("\r\n")),g=f.get("pcma")||[],v=f.get("pcmu")||[];return("audio"===p?new Set(g.concat(v)):new Set).has(h[0])?m.replace(/\r\nb=(AS|TIAS):([0-9]+)/g,""):m})).join("\r\n")}},11082:function(e,t,n){"use strict";var r=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r};Object.defineProperty(t,"__esModule",{value:!0}),t.getRTCIceCandidateStatsReport=t.getRTCStats=void 0;var i=n(12861),o=n(79671);function a(e,t){return"function"==typeof e.get?e.get(t):e.find(function(e){return e.id===t})}function s(e){var t;if(!e)return Promise.reject(new i.InvalidArgumentError("PeerConnection is null"));if("function"!=typeof e.getStats)return Promise.reject(new i.NotSupportedError("WebRTC statistics are unsupported"));try{t=e.getStats()}catch(n){t=new Promise(function(t){return e.getStats(t)}).then(o.default.fromRTCStatsResponse)}return t}function c(){}function u(e){var t,n=null,r=new c;Array.from(e.values()).forEach(function(i){if(!i.isRemote){var o=i.type.replace("-","");if(t=t||i.timestamp,i.remoteId){var s=a(e,i.remoteId);s&&s.roundTripTime&&(r.rtt=1e3*s.roundTripTime)}switch(o){case"inboundrtp":r.timestamp=r.timestamp||i.timestamp,r.jitter=1e3*i.jitter,r.packetsLost=i.packetsLost,r.packetsReceived=i.packetsReceived,r.bytesReceived=i.bytesReceived;break;case"outboundrtp":if(r.timestamp=i.timestamp,r.packetsSent=i.packetsSent,r.bytesSent=i.bytesSent,i.codecId){var c=a(e,i.codecId);r.codecName=c?c.mimeType&&c.mimeType.match(/(.*\/)?(.*)/)[2]:i.codecId}break;case"transport":n=i.id}}}),r.timestamp||(r.timestamp=t);var i=a(e,n);if(!i)return r;var o=a(e,i.selectedCandidatePairId);if(!o)return r;var s=a(e,o.localCandidateId),u=a(e,o.remoteCandidateId);return r.rtt||(r.rtt=o&&1e3*o.currentRoundTripTime),Object.assign(r,{localAddress:s&&(s.address||s.ip),remoteAddress:u&&(u.address||u.ip)}),r}t.getRTCStats=function(e,t){return t=Object.assign({createRTCSample:u},t),s(e).then(t.createRTCSample)},t.getRTCIceCandidateStatsReport=function(e){return s(e).then(function(e){var t,n=Array.from(e.values()).reduce(function(e,t){switch(["candidatePairs","localCandidates","remoteCandidates"].forEach(function(t){e[t]||(e[t]=[])}),t.type){case"candidate-pair":e.candidatePairs.push(t);break;case"local-candidate":e.localCandidates.push(t);break;case"remote-candidate":e.remoteCandidates.push(t);break;case"transport":t.selectedCandidatePairId&&(e.transport=t)}return e},{}),i=n.candidatePairs,o=n.localCandidates,a=n.remoteCandidates,s=n.transport,c=i.find(function(e){return e.selected||s&&e.id===s.selectedCandidatePairId});return c&&(t={localCandidate:o.find(function(e){return e.id===c.localCandidateId}),remoteCandidate:a.find(function(e){return e.id===c.remoteCandidateId})}),{iceCandidateStats:r(o,a),selectedIceCandidatePairStats:t}})}},14186:function(e,t){"use strict";
1Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){Object.defineProperties(this,{deviceId:{get:function(){return e.deviceId}},groupId:{get:function(){return e.groupId}},kind:{get:function(){return e.kind}},label:{get:function(){return e.label}}})}},50070:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(24548),i=n(13600),o=n(12861);function a(e,t,n){if(!(this instanceof a))return new a(e,t,n);if(!e||!t)throw new o.InvalidArgumentError("name and url are required arguments");(n=Object.assign({AudioFactory:"undefined"!=typeof Audio?Audio:null,maxDuration:0,shouldLoop:!1},n)).AudioPlayer=n.audioContext?i.default.bind(i.default,n.audioContext):n.AudioFactory,Object.defineProperties(this,{_Audio:{value:n.AudioPlayer},_activeEls:{value:new Map},_isSinkSupported:{value:null!==n.AudioFactory&&"function"==typeof n.AudioFactory.prototype.setSinkId},_maxDuration:{value:n.maxDuration},_maxDurationTimeout:{value:null,writable:!0},_operations:{value:new r.AsyncQueue},_playPromise:{value:null,writable:!0},_shouldLoop:{value:n.shouldLoop},_sinkIds:{value:["default"]},isPlaying:{enumerable:!0,get:function(){return!!this._playPromise}},name:{enumerable:!0,value:e},url:{enumerable:!0,value:t}}),this._Audio&&this._play(!0,!1)}function s(e){e&&(e.pause(),e.src="",e.srcObject=null,e.load())}a.prototype._playAudioElement=function(e,t,n){var r=this,i=this._activeEls.get(e);if(!i)throw new o.InvalidArgumentError('sinkId: "'+e+"\" doesn't have an audio element");return i.muted=!!t,i.loop=!!n,i.play().then(function(){return i}).catch(function(t){throw s(i),r._activeEls.delete(e),t})},a.prototype._play=function(e,t){this.isPlaying&&this._stop(),this._maxDuration>0&&(this._maxDurationTimeout=setTimeout(this._stop.bind(this),this._maxDuration)),t="boolean"==typeof t?t:this._shouldLoop;var n=this;return this._playPromise=Promise.all(this._sinkIds.map(function(r){if(!n._Audio)return Promise.resolve();var i=n._activeEls.get(r);return i?n._playAudioElement(r,e,t):("function"==typeof(i=new n._Audio(n.url)).setAttribute&&i.setAttribute("crossorigin","anonymous"),new Promise(function(e){i.addEventListener("canplaythrough",e)}).then(function(){return(n._isSinkSupported?i.setSinkId(r):Promise.resolve()).then(function(){return(n._activeEls.set(r,i),n._playPromise)?n._playAudioElement(r,e,t):Promise.resolve()})}))}))},a.prototype._stop=function(){var e=this;this._activeEls.forEach(function(t,n){e._sinkIds.includes(n)?(t.pause(),t.currentTime=0):(s(t),e._activeEls.delete(n))}),clearTimeout(this._maxDurationTimeout),this._playPromise=null,this._maxDurationTimeout=null},a.prototype.setSinkIds=function(e){this._isSinkSupported&&(e=e.forEach?e:[e],[].splice.apply(this._sinkIds,[0,this._sinkIds.length].concat(e)))},a.prototype.stop=function(){var e=this;this._operations.enqueue(function(){return e._stop(),Promise.resolve()})},a.prototype.play=function(){var e=this;return this._operations.enqueue(function(){return e._play()})},t.default=a},74455:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},a=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r};Object.defineProperty(t,"__esModule",{value:!0});var s=n(55445),c=n(12861),u=n(82413),d=n(11082),l=n(41262),p={audioInputLevel:{minStandardDeviation:327.67,sampleCount:10},audioOutputLevel:{minStandardDeviation:327.67,sampleCount:10}
1,bytesReceived:{clearCount:2,min:1,raiseCount:3,sampleCount:3},bytesSent:{clearCount:2,min:1,raiseCount:3,sampleCount:3},jitter:{max:30},mos:{min:3},packetsLostFraction:[{max:1},{clearValue:1,maxAverage:3,sampleCount:7}],rtt:{max:400}},f=function(e){function t(t){var n=e.call(this)||this;n._activeWarnings=new Map,n._currentStreaks=new Map,n._inputVolumes=[],n._outputVolumes=[],n._sampleBuffer=[],n._supplementalSampleBuffers={audioInputLevel:[],audioOutputLevel:[]},n._warningsEnabled=!0,t=t||{},n._getRTCStats=t.getRTCStats||d.getRTCStats,n._mos=t.Mos||u.default,n._peerConnection=t.peerConnection,n._thresholds=o(o({},p),t.thresholds);var r=Object.values(n._thresholds).map(function(e){return e.sampleCount}).filter(function(e){return!!e});return n._maxSampleCount=Math.max.apply(Math,a([5],r)),n._peerConnection&&n.enable(n._peerConnection),n}return i(t,e),t.prototype.addVolumes=function(e,t){this._inputVolumes.push(e),this._outputVolumes.push(t)},t.prototype.disable=function(){return this._sampleInterval&&(clearInterval(this._sampleInterval),delete this._sampleInterval),this},t.prototype.disableWarnings=function(){return this._warningsEnabled&&this._activeWarnings.clear(),this._warningsEnabled=!1,this},t.prototype.enable=function(e){if(e){if(this._peerConnection&&e!==this._peerConnection)throw new c.InvalidArgumentError("Attempted to replace an existing PeerConnection in StatsMonitor.enable");this._peerConnection=e}if(!this._peerConnection)throw new c.InvalidArgumentError("Can not enable StatsMonitor without a PeerConnection");return this._sampleInterval=this._sampleInterval||setInterval(this._fetchSample.bind(this),1e3),this},t.prototype.enableWarnings=function(){return this._warningsEnabled=!0,this},t.prototype.hasActiveWarning=function(e,t){return!!this._activeWarnings.get(e+":"+t)},t.prototype._addSample=function(e){var t=this._sampleBuffer;t.push(e),t.length>this._maxSampleCount&&t.splice(0,t.length-this._maxSampleCount)},t.prototype._clearWarning=function(e,t,n){var r=e+":"+t,i=this._activeWarnings.get(r);!i||Date.now()-i.timeRaised<5e3||(this._activeWarnings.delete(r),this.emit("warning-cleared",o(o({},n),{name:e,threshold:{name:t,value:this._thresholds[e][t]}})))},t.prototype._createSample=function(e,t){var n=t&&t.totals.bytesSent||0,r=t&&t.totals.bytesReceived||0,i=t&&t.totals.packetsSent||0,o=t&&t.totals.packetsReceived||0,a=t&&t.totals.packetsLost||0,s=e.bytesSent-n,
1c=e.bytesReceived-r,u=e.packetsSent-i,d=e.packetsReceived-o,p=e.packetsLost-a,f=d+p,h=f>0?p/f*100:0,m=e.packetsReceived+e.packetsLost,g=m>0?e.packetsLost/m*100:100,v="number"!=typeof e.rtt&&t?t.rtt:e.rtt,_=this._inputVolumes.splice(0);this._supplementalSampleBuffers.audioInputLevel.push(_);var y=this._outputVolumes.splice(0);return this._supplementalSampleBuffers.audioOutputLevel.push(y),{audioInputLevel:Math.round(l.average(_)),audioOutputLevel:Math.round(l.average(y)),bytesReceived:c,bytesSent:s,codecName:e.codecName,jitter:e.jitter,mos:this._mos.calculate(v,e.jitter,t&&h),packetsLost:p,packetsLostFraction:h,packetsReceived:d,packetsSent:u,rtt:v,timestamp:e.timestamp,totals:{bytesReceived:e.bytesReceived,bytesSent:e.bytesSent,packetsLost:e.packetsLost,packetsLostFraction:g,packetsReceived:e.packetsReceived,packetsSent:e.packetsSent}}},t.prototype._fetchSample=function(){var e=this;this._getSample().then(function(t){e._addSample(t),e._raiseWarnings(),e.emit("sample",t)}).catch(function(t){e.disable(),e.emit("error",t)})},t.prototype._getSample=function(){var e=this;return this._getRTCStats(this._peerConnection).then(function(t){var n=null;return e._sampleBuffer.length&&(n=e._sampleBuffer[e._sampleBuffer.length-1]),e._createSample(t,n)})},t.prototype._raiseWarning=function(e,t,n){var r,i=e+":"+t;if(!this._activeWarnings.has(i)){this._activeWarnings.set(i,{timeRaised:Date.now()});var a=this._thresholds[e];if(Array.isArray(a)){var s=a.find(function(e){return t in e});s&&(r=s[t])}else r=this._thresholds[e][t];this.emit("warning",o(o({},n),{name:e,threshold:{name:t,value:r}}))}},t.prototype._raiseWarnings=function(){var e=this;this._warningsEnabled&&Object.keys(this._thresholds).forEach(function(t){return e._raiseWarningsForStat(t)})},t.prototype._raiseWarningsForStat=function(e){var t=this;(Array.isArray(this._thresholds[e])?this._thresholds[e]:[this._thresholds[e]]).forEach(function(n){var r,i,o,s=t._sampleBuffer,c=n.clearCount||0,u=n.raiseCount||3,d=n.sampleCount||t._maxSampleCount,p=s.slice(-d),f=p.map(function(t){return t[e]});if(!f.some(function(e){return null==e})){if("number"==typeof n.max&&(r=n.max,(o=f.reduce(function(e,t){return e+(t>r?1:0)},0))>=u?t._raiseWarning(e,"max",{values:f,samples:p}):o<=c&&t._clearWarning(e,"max",{values:f,samples:p})),"number"==typeof n.min&&(i=n.min,(o=f.reduce(function(e,t){return e+(t<i?1:0)},0))>=u?t._raiseWarning(e,"min",{values:f,samples:p}):o<=c&&t._clearWarning(e,"min",{values:f,samples:p})),"number"==typeof n.maxDuration&&s.length>1){var h=(p=s.slice(-2))[0][e],m=p[1][e],g=t._currentStreaks.get(e)||0,v=h===m?g+1:0;t._currentStreaks.set(e,v),v>=n.maxDuration?t._raiseWarning(e,"maxDuration",{value:v}):0===v&&t._clearWarning(e,"maxDuration",{value:g})}if("number"==typeof n.minStandardDeviation){var _=t._supplementalSampleBuffers[e];if(!_||_.length<n.sampleCount)return;_.length>n.sampleCount&&_.splice(0,_.length-n.sampleCount);var y=function(e){if(e.length<=0)return null;var t=e.reduce(function(e,t){return e+t},0)/e.length,n=e.map(function(e){return Math.pow(e-t,2)});return Math.sqrt(n.reduce(function(e,t){return e+t},0)/n.length)}(_.slice(-d).reduce(function(e,t){return a(e,t)},[]));if("number"!=typeof y)return;y<n.minStandardDeviation?t._raiseWarning(e,"minStandardDeviation",{value:y}):t._clearWarning(e,"minStandardDeviation",{value:y})}[["maxAverage",function(e,t){return e>t}],["minAverage",function(e,t){return e<t}]].forEach(function(r){var i=r[0],o=r[1];if("number"==typeof n[i]&&f.length>=d){var a=l.average(f);o(a,n[i])?t._raiseWarning(e,i,{values:f,samples:p}):o(a,n.clearValue||n[i])||t._clearWarning(e,i,{values:f,samples:p})}})}})},t}(s.EventEmitter);t.default=f},41262:function(e,t,n){"use strict";function r(e){if(!(this instanceof r))return new r(e);this.message=e}function i(e){return!!e.userAgent.match("Electron")}function o(e,t){var n=!!t.userAgent.match("CriOS"),r=!!t.userAgent.match("HeadlessChrome"),o=void 0!==e.chrome&&"Google Inc."===t.vendor&&-1===t.userAgent.indexOf("OPR")&&-1===t.userAgent.indexOf("Edge");return n||i(t)||o||r}function a(e){return!!(e=e||("undefined"==typeof window?n.g.navigator:window.navigator))&&"string"==typeof e.userAgent&&/firefox|fxios/i.test(e.userAgent)}function s(e){return!!e.vendor&&-1!==e.vendor.indexOf("Apple")&&e.userAgent&&-1===e.userAgent.indexOf("CriOS")&&-1===e.userAgent.indexOf("FxiOS")}
1Object.defineProperty(t,"__esModule",{value:!0}),t.promisifyEvents=t.flatMap=t.queryToJson=t.isUnifiedPlanDefault=t.isSafari=t.isLegacyEdge=t.isFirefox=t.isChrome=t.isElectron=t.difference=t.average=t.Exception=void 0,r.prototype.toString=function(){return"Twilio.Exception: "+this.message},t.average=function(e){return e&&e.length?e.reduce(function(e,t){return e+t})/e.length:0},t.difference=function(e,t,n){n=n||function(e){return e};var r=new Set(t.map(n));return e.filter(function(e){return!r.has(n(e))})},t.isElectron=i,t.isChrome=o,t.isFirefox=a,t.isLegacyEdge=function(e){return!!(e=e||("undefined"==typeof window?n.g.navigator:window.navigator))&&"string"==typeof e.userAgent&&/edge\/\d+/i.test(e.userAgent)},t.isSafari=s,t.isUnifiedPlanDefault=function(e,t,n,r){if(void 0===e||void 0===t||void 0===n||void 0===r||void 0===n.prototype||void 0===r.prototype)return!1;if(o(e,t)&&n.prototype.addTransceiver){var i=new n,c=!0;try{i.addTransceiver("audio")}catch(e){c=!1}return i.close(),c}return!!a(t)||!!s(t)&&"currentDirection"in r.prototype},t.queryToJson=function(e){return e?e.split("&").reduce(function(e,t){var n=t.split("="),r=n[0],i=decodeURIComponent((n[1]||"").replace(/\+/g,"%20"));return r&&(e[r]=i),e},{}):""},t.flatMap=function(e,t){var n=e instanceof Map||e instanceof Set?Array.from(e.values()):e;return t=t||function(e){return e},n.reduce(function(e,n){var r=t(n);return e.concat(r)},[])},t.promisifyEvents=function(e,t,n){return new Promise(function(r,i){function o(){e.removeListener(n,a),r()}function a(){e.removeListener(t,o),i()}e.once(t,o),e.once(n,a)})},t.Exception=r},89157:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateVoiceEventSid=void 0;var r=n(90684),i=n(12861),o="function"==typeof r?r:r.default;t.generateVoiceEventSid=function(){return"KX"+function(){if("object"!=typeof window)throw new i.NotSupportedError("This platform is not supported.");var e=window.crypto;if("object"!=typeof e)throw new i.NotSupportedError("The `crypto` module is not available on this platform.");if(void 0===(e.randomUUID||e.getRandomValues))throw new i.NotSupportedError("Neither `crypto.randomUUID` or `crypto.getRandomValues` are available on this platform.");if(void 0===window.Uint32Array)throw new i.NotSupportedError("The `Uint32Array` module is not available on this platform.");return o(("function"==typeof e.randomUUID?function(){return e.randomUUID()}:function(){return e.getRandomValues(new Uint32Array(32)).toString()})())}()}},25889:function(e,t,n){"use strict";var r,i,o,a=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),s=this&&this.__assign||function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.WSTransportState=void 0;var c=n(55445),u=n(87921),d=n(12861),l=n(92764),p=globalThis.WebSocket,f=1/0;(r=o=t.WSTransportState||(t.WSTransportState={})).Connecting="connecting",r.Closed="closed",r.Open="open";var h=function(e){function t(n,r){void 0===r&&(r={});var i=e.call(this)||this;return i.state=o.Closed,i._backoffStartTime={preferred:null,primary:null},i._connectedUri=null,i._log=new l.default("WSTransport"),i._shouldFallback=!1,i._uriIndex=0,i._moveUriIndex=function(){i._uriIndex++,i._uriIndex>=i._uris.length&&(i._uriIndex=0)},i._onSocketClose=function(e){if(i._log.error("Received websocket close event code: "+e.code+". Reason: "+e.reason),1006===e.code||1015===e.code){i.emit("error",{code:31005,message:e.reason||"Websocket connection to Twilio's signaling servers were unexpectedly ended. If this is happening consistently, there may be an issue resolving the hostname provided. If a region or an edge is being specified in Device setup, ensure it is valid.",twilioError:ne
1w d.SignalingErrors.ConnectionError});var t=i.state===o.Open||i._previousState===o.Open;(i._shouldFallback||!t)&&i._moveUriIndex(),i._shouldFallback=!0}i._closeSocket()},i._onSocketError=function(e){i._log.error("WebSocket received error: "+e.message),i.emit("error",{code:31e3,message:e.message||"WSTransport socket error",twilioError:new d.SignalingErrors.ConnectionDisconnected})},i._onSocketMessage=function(e){if(i._setHeartbeatTimeout(),i._socket&&"\n"===e.data){i._socket.send("\n"),i._log.debug("heartbeat");return}e&&"string"==typeof e.data&&i._log.debug("Received: "+e.data),i.emit("message",e)},i._onSocketOpen=function(){i._log.info("WebSocket opened successfully."),i._timeOpened=Date.now(),i._shouldFallback=!1,i._setState(o.Open),clearTimeout(i._connectTimeout),i._resetBackoffs(),i._setHeartbeatTimeout(),i.emit("open")},i._options=s(s({},t.defaultConstructorOptions),r),i._uris=n,i._backoff=i._setupBackoffs(),i}return a(t,e),t.prototype.close=function(){this._log.info("WSTransport.close() called..."),this._close()},t.prototype.open=function(){if(this._log.info("WSTransport.open() called..."),this._socket&&(this._socket.readyState===p.CONNECTING||this._socket.readyState===p.OPEN)){this._log.info("WebSocket already open.");return}this._preferredUri?this._connect(this._preferredUri):this._connect(this._uris[this._uriIndex])},t.prototype.send=function(e){if(this._log.debug("Sending: "+e),!this._socket||this._socket.readyState!==p.OPEN)return this._log.debug("Cannot send message. WebSocket is not open."),!1;try{this._socket.send(e)}catch(e){return this._log.error("Error while sending message:",e.message),this._closeSocket(),!1}return!0},t.prototype.updatePreferredURI=function(e){this._preferredUri=e},t.prototype.updateURIs=function(e){"string"==typeof e&&(e=[e]),this._uris=e,this._uriIndex=0},t.prototype._close=function(){this._setState(o.Closed),this._closeSocket()},t.prototype._closeSocket=function(){if(clearTimeout(this._connectTimeout),clearTimeout(this._heartbeatTimeout),this._log.info("Closing and cleaning up WebSocket..."),!this._socket){this._log.info("No WebSocket to clean up.");return}this._socket.removeEventListener("close",this._onSocketClose),this._socket.removeEventListener("error",this._onSocketError),this._socket.removeEventListener("message",this._onSocketMessage),this._socket.removeEventListener("open",this._onSocketOpen),(this._socket.readyState===p.CONNECTING||this._socket.readyState===p.OPEN)&&this._socket.close(),this._timeOpened&&Date.now()-this._timeOpened>1e4&&this._resetBackoffs(),this.state!==o.Closed&&this._performBackoff(),delete this._socket,this.emit("close")},t.prototype._connect=function(e,t){var n=this;this._log.info("number"==typeof t?"Attempting to reconnect (retry #"+t+")...":"Attempting to connect..."),this._closeSocket(),this._setState(o.Connecting),this._connectedUri=e;try{this._socket=new this._options.WebSocket(this._connectedUri)}catch(e){this._log.error("Could not connect to endpoint:",e.message),this._close(),this.emit("error",{code:31e3,message:e.message||"Could not connect to "+this._connectedUri,twilioError:new d.SignalingErrors.ConnectionDisconnected});return}this._socket.addEventListener("close",this._onSocketClose),this._socket.addEventListener("error",this._onSocketError),this._socket.addEventListener("message",this._onSocketMessage),this._socket.addEventListener("open",this._onSocketOpen),delete this._timeOpened,this._connectTimeout=setTimeout(function(){n._log.info("WebSocket connection attempt timed out."),n._moveUriIndex(),n._closeSocket()},this._options.connectTimeoutMs)},t.prototype._performBackoff=function(){this._preferredUri?(this._log.info("Preferred URI set; backing off."),this._backoff.preferred.backoff()):(this._log.info("Preferred URI not set; backing off."),this._backoff.primary.backoff())},t.prototype._resetBackoffs=function(){this._backoff.preferred.reset(),this._backoff.primary.reset(),this._backoffStartTime.preferred=null,this._backoffStartTime.primary=null},t.prototype._setHeartbeatTimeout=function(){var e=this;clearTimeout(this._heartbeatTimeout),this._heartbeatTimeout=setTimeout(function(){e._log.info("No messages received in 15 seconds. Reconnecting..."),e._shouldFallback=!0,e._closeSocket()},15e3)},t.prototype._setState=function(e){this._previousState=this.state,this.state=e},t.prototype._setupBackoffs=function(){var e=this,t={factor:2,jitter:.4,max:this._options.maxPreferredDelayMs,min:100};this._log.info("Initializing preferred transport backoff using config: ",t);var n=new u.default(t);
1n.on("backoff",function(t,n){if(e.state===o.Closed){e._log.info("Preferred backoff initiated but transport state is closed; not attempting a connection.");return}e._log.info("Will attempt to reconnect Websocket to preferred URI in "+n+"ms"),0===t&&(e._backoffStartTime.preferred=Date.now(),e._log.info("Preferred backoff start; "+e._backoffStartTime.preferred))}),n.on("ready",function(t,n){if(e.state===o.Closed){e._log.info("Preferred backoff ready but transport state is closed; not attempting a connection.");return}if(null===e._backoffStartTime.preferred){e._log.info("Preferred backoff start time invalid; not attempting a connection.");return}if(Date.now()-e._backoffStartTime.preferred>e._options.maxPreferredDurationMs){e._log.info("Max preferred backoff attempt time exceeded; falling back to primary backoff."),e._preferredUri=null,e._backoff.primary.backoff();return}if("string"!=typeof e._preferredUri){e._log.info("Preferred URI cleared; falling back to primary backoff."),e._preferredUri=null,e._backoff.primary.backoff();return}e._connect(e._preferredUri,t+1)});var r={factor:2,jitter:.4,max:this._options.maxPrimaryDelayMs,min:this._uris&&this._uris.length>1?Math.floor(4001*Math.random())+1e3:100};this._log.info("Initializing primary transport backoff using config: ",r);var i=new u.default(r);return i.on("backoff",function(t,n){if(e.state===o.Closed){e._log.info("Primary backoff initiated but transport state is closed; not attempting a connection.");return}e._log.info("Will attempt to reconnect WebSocket in "+n+"ms"),0===t&&(e._backoffStartTime.primary=Date.now(),e._log.info("Primary backoff start; "+e._backoffStartTime.primary))}),i.on("ready",function(t,n){if(e.state===o.Closed){e._log.info("Primary backoff ready but transport state is closed; not attempting a connection.");return}if(null===e._backoffStartTime.primary){e._log.info("Primary backoff start time invalid; not attempting a connection.");return}if(Date.now()-e._backoffStartTime.primary>e._options.maxPrimaryDurationMs){e._log.info("Max primary backoff attempt time exceeded; not attempting a connection.");return}e._connect(e._uris[e._uriIndex],t+1)}),{preferred:n,primary:i}},Object.defineProperty(t.prototype,"uri",{get:function(){return this._connectedUri},enumerable:!1,configurable:!0}),t.defaultConstructorOptions={WebSocket:p,connectTimeoutMs:5e3,maxPreferredDelayMs:1e3,maxPreferredDurationMs:15e3,maxPrimaryDelayMs:2e4,maxPrimaryDurationMs:f},t}(c.EventEmitter);t.default=h},90442:function(e){var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=t},79625:function(e){var t,n;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],r=0;r<e.length;r+=3)for(var i=e[r]<<16|e[r+1]<<8|e[r+2],o=0;o<4;o++)8*r+6*o<=8*e.length?n.push(t.charAt(i>>>6*(3-o)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/ig,"");for(var n=[],r=0,i=0;r<e.length;i=++r%4)0!=i&&n.push((t.indexOf(e.charAt(r-1))&Math.pow(2,-2*i+8)-1)<<2*i|t.indexOf(e.charAt(r))>>>6-2*i);return n}},e.exports=n},55445:function(e){"use strict";var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=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 i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(n,r){var i;function o(n){e.removeListener(t,a),r(n)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}m(e,t,a,{once:!0}),"error"!==t&&(i={once:!0},"function"==typeof e.on&&m(e,"error",o,i))})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(e){if("function"!=typeof e)throw TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,n,r){if(s(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),void 0===a)a=o[t]=n,++e._eventsCount;else if("function"==typeof a?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=c(e))>0&&a.length>i&&!a.warned){a.warned=!0;var i,o,a,u=Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,console&&console.warn&&console.warn(u)}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 l(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=d.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):h(i,i.length)}function f(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function h(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function m(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else if("function"==typeof e.addEventListener)e.addEventListener(t,function i(o){r.once&&e.removeEventListener(t,i),n(o)});else throw TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a}
1,set:function(e){if("number"!=typeof e||e<0||i(e))throw RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=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||i(e))throw RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var a,s=Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)r(c,this,t);else for(var u=c.length,d=h(c,u),n=0;n<u;++n)r(d[n],this,t);return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return s(t),this.on(e,l(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return s(t),this.prependListener(e,l(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,r,i,o,a;if(s(t),void 0===(r=this._events)||void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,a||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0==arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0==arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);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):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},86005:function(e,t,n){var r,i;void 0!==(i="function"==typeof(r=function(){"use strict";var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"];function i(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function a(t,n){for(var i=0;i<r.length;i++){var o=r[i];this[o]=i<t?e:this.methodFactory(o,t,n)}this.log=this.debug}function s(e,n,r){return function(){typeof console!==t&&(a.call(this,n,r),this[e].apply(this,arguments))}}function c(r,a,c){var u;return"debug"===(u=r)&&(u="log"),typeof console!==t&&("trace"===u&&n?o:void 0!==console[u]?i(console,u):void 0!==console.log?i(console,"log"):e)||s.apply(this,arguments)}function u(e,n,i){var o,s=this,u="loglevel";function d(){var e;if(typeof window!==t){try{e=window.localStorage[u]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,r=n.indexOf(encodeURIComponent(u)+"=");-1!==r&&(e=/^([^;]+)/.exec(n.slice(r))[1])}catch(e){}return void 0===s.levels[e]&&(e=void 0),e}}e&&(u+=":"+e),s.name=e,s.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},s.methodFactory=i||c,s.getLevel=function(){return o}
1,s.setLevel=function(n,i){if("string"==typeof n&&void 0!==s.levels[n.toUpperCase()]&&(n=s.levels[n.toUpperCase()]),"number"==typeof n&&n>=0&&n<=s.levels.SILENT){if(o=n,!1!==i&&function(e){var n=(r[e]||"silent").toUpperCase();if(typeof window!==t){try{window.localStorage[u]=n;return}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"="+n+";"}catch(e){}}}(n),a.call(s,n,e),typeof console===t&&n<s.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+n},s.setDefaultLevel=function(e){d()||s.setLevel(e,!1)},s.enableAll=function(e){s.setLevel(s.levels.TRACE,e)},s.disableAll=function(e){s.setLevel(s.levels.SILENT,e)};var l=d();null==l&&(l=null==n?"WARN":n),s.setLevel(l,!1)}var d=new u,l={};d.getLogger=function(e){if("string"!=typeof e||""===e)throw TypeError("You must supply a name when creating a logger.");var t=l[e];return t||(t=l[e]=new u(e,d.getLevel(),d.methodFactory)),t};var p=typeof window!==t?window.log:void 0;return d.noConflict=function(){return typeof window!==t&&window.log===d&&(window.log=p),d},d.getLoggers=function(){return l},d})?r.call(t,n,t,e):r)&&(e.exports=i)},90684:function(e,t,n){var r,i,o,a,s;r=n(79625),i=n(90442).utf8,o=n(72881),a=n(90442).bin,(s=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?a.stringToBytes(e):i.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=r.bytesToWords(e),c=8*e.length,u=1732584193,d=-271733879,l=-1732584194,p=271733878,f=0;f<n.length;f++)n[f]=(n[f]<<8|n[f]>>>24)&16711935|(n[f]<<24|n[f]>>>8)&4278255360;n[c>>>5]|=128<<c%32,n[(c+64>>>9<<4)+14]=c;for(var h=s._ff,m=s._gg,g=s._hh,v=s._ii,f=0;f<n.length;f+=16){var _=u,y=d,b=l,S=p;u=h(u,d,l,p,n[f+0],7,-680876936),p=h(p,u,d,l,n[f+1],12,-389564586),l=h(l,p,u,d,n[f+2],17,606105819),d=h(d,l,p,u,n[f+3],22,-1044525330),u=h(u,d,l,p,n[f+4],7,-176418897),p=h(p,u,d,l,n[f+5],12,1200080426),l=h(l,p,u,d,n[f+6],17,-1473231341),d=h(d,l,p,u,n[f+7],22,-45705983),u=h(u,d,l,p,n[f+8],7,1770035416),p=h(p,u,d,l,n[f+9],12,-1958414417),l=h(l,p,u,d,n[f+10],17,-42063),d=h(d,l,p,u,n[f+11],22,-1990404162),u=h(u,d,l,p,n[f+12],7,1804603682),p=h(p,u,d,l,n[f+13],12,-40341101),l=h(l,p,u,d,n[f+14],17,-1502002290),d=h(d,l,p,u,n[f+15],22,1236535329),u=m(u,d,l,p,n[f+1],5,-165796510),p=m(p,u,d,l,n[f+6],9,-1069501632),l=m(l,p,u,d,n[f+11],14,643717713),d=m(d,l,p,u,n[f+0],20,-373897302),u=m(u,d,l,p,n[f+5],5,-701558691),p=m(p,u,d,l,n[f+10],9,38016083),l=m(l,p,u,d,n[f+15],14,-660478335),d=m(d,l,p,u,n[f+4],20,-405537848),u=m(u,d,l,p,n[f+9],5,568446438),p=m(p,u,d,l,n[f+14],9,-1019803690),l=m(l,p,u,d,n[f+3],14,-187363961),d=m(d,l,p,u,n[f+8],20,1163531501),u=m(u,d,l,p,n[f+13],5,-1444681467),p=m(p,u,d,l,n[f+2],9,-51403784),l=m(l,p,u,d,n[f+7],14,1735328473),d=m(d,l,p,u,n[f+12],20,-1926607734),u=g(u,d,l,p,n[f+5],4,-378558),p=g(p,u,d,l,n[f+8],11,-2022574463),l=g(l,p,u,d,n[f+11],16,1839030562),d=g(d,l,p,u,n[f+14],23,-35309556),u=g(u,d,l,p,n[f+1],4,-1530992060),p=g(p,u,d,l,n[f+4],11,1272893353),l=g(l,p,u,d,n[f+7],16,-155497632),d=g(d,l,p,u,n[f+10],23,-1094730640),u=g(u,d,l,p,n[f+13],4,681279174),p=g(p,u,d,l,n[f+0],11,-358537222),l=g(l,p,u,d,n[f+3],16,-722521979),d=g(d,l,p,u,n[f+6],23,76029189),u=g(u,d,l,p,n[f+9],4,-640364487),p=g(p,u,d,l,n[f+12],11,-421815835),l=g(l,p,u,d,n[f+15],16,530742520),d=g(d,l,p,u,n[f+2],23,-995338651),u=v(u,d,l,p,n[f+0],6,-198630844),p=v(p,u,d,l,n[f+7],10,1126891415),l=v(l,p,u,d,n[f+14],15,-1416354905),d=v(d,l,p,u,n[f+5],21,-57434055),u=v(u,d,l,p,n[f+12],6,1700485571),p=v(p,u,d,l,n[f+3],10,-1894986606),l=v(l,p,u,d,n[f+10],15,-1051523),d=v(d,l,p,u,n[f+1],21,-2054922799),u=v(u,d,l,p,n[f+8],6,1873313359),p=v(p,u,d,l,n[f+15],10,-30611744),l=v(l,p,u,d,n[f+6],15,-1560198380),d=v(d,l,p,u,n[f+13],21,1309151649),u=v(u,d,l,p,n[f+4],6,-145523070),p=v(p,u,d,l,n[f+11],10,-1120210379),l=v(l,p,u,d,n[f+2],15,718787259),d=v(d,l,p,u,n[f+9],21,-343485551),u=u+_>>>0,d=d+y>>>0,l=l+b>>>0,p=p+S>>>0}return r.endian([u,d,l,p])})._ff=function(e,t,n,r,i,o,a){var s=e+(t&n|~t&r)+(i>>>0)+a;return(s<<o|s>>>32-o)+t},s._gg=function(e,t,n,r,i,o,a){var s=e+(t&r|n&~r)+(i>>>0)+a;return(s<<o|s>>>32-o)+t},s._hh=function(e,t,n,r,i,o,a){var s=e+(t^n^r)+(i>>>0)+a;return(s<<o|s>>>32-o)+t},s._ii=function(e,t,n,r,i,o,a){var s=e+(n^(t|~r))+(i>>>0)+a;return(s<<o|s>>>32-o)+t},s._blocksize=16,s._digestsize=16,e.exports=function(e,t){if(null==e)throw Error("Illegal argument "+e);var n=r.wordsToBytes(s(e,t));return t&&t.asBytes?n:t&&t.asString?a.bytesToString(n):r.bytesToHex(n)}},72881:function(e){function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))||!!e._isBuffer)}},74421:function(e,t,n){"use strict";var r=n(40802);function i(e,t,n,i,o){var a=r.writeRtpDescription(e.kind,t);
1if(a+=r.writeIceParameters(e.iceGatherer.getLocalParameters())+r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":o||"active")+"a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var s=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=s;var c="msid:"+(i?i.id:"-")+" "+s+"\r\n";a+="a="+c+("a=ssrc:"+e.sendEncodingParameters[0].ssrc)+" "+c,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c+("a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" ")+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),a}function o(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n<t.length;n++)if(t[n].payloadType===e||t[n].preferredPayloadType===e)return t[n]},i=function(e,t,n,i){var o=r(e.parameters.apt,n),a=r(t.parameters.apt,i);return o&&a&&o.name.toLowerCase()===a.name.toLowerCase()};return e.codecs.forEach(function(r){for(var o=0;o<t.codecs.length;o++){var a=t.codecs[o];if(r.name.toLowerCase()===a.name.toLowerCase()&&r.clockRate===a.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&a.parameters.apt&&!i(r,a,e.codecs,t.codecs))continue;(a=JSON.parse(JSON.stringify(a))).numChannels=Math.min(r.numChannels,a.numChannels),n.codecs.push(a),a.rtcpFeedback=a.rtcpFeedback.filter(function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}}),n}function a(e,t,n){return -1!==({offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}})[t][e].indexOf(n)}function s(e,t){var n=e.getRemoteCandidates().find(function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type});return n||e.addRemoteCandidate(t),!n}function c(e,t){var n=Error(t);return n.name=e,n}e.exports=function(e,t){function n(t,n){n.addTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function u(t,n,r,i){var o=new Event("track");o.track=n,o.receiver=r,o.transceiver={receiver:r},o.streams=i,e.setTimeout(function(){t._dispatchEvent("track",o)})}var d=function(n){var i,o,a=this,s=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){a[e]=s[e].bind(s)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this.localDescription=null,this.remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.iceGatheringState="new",n=JSON.parse(JSON.stringify(n||{})),this.usingBundle="max-bundle"===n.bundlePolicy,"negotiate"===n.rtcpMuxPolicy)throw c("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(n.rtcpMuxPolicy||(n.rtcpMuxPolicy="require"),n.iceTransportPolicy){case"all":case"relay":break;default:n.iceTransportPolicy="all"}switch(n.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:n.bundlePolicy="balanced"}if(n.iceServers=(i=n.iceServers||[],o=!1,(i=JSON.parse(JSON.stringify(i))).filter(function(e){if(e&&(e.urls||e.url)){var n=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var r="string"==typeof n;return r&&(n=[n]),n=n.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||o?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(o=!0,!0)}),delete e.url,e.urls=r?n[0]:n,!!n.length}})),this._iceGatherers=[],n.iceCandidatePoolSize)for(var u=n.iceCandidatePoolSize;u>0;u--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=r.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1}
1;d.prototype.onicecandidate=null,d.prototype.onaddstream=null,d.prototype.ontrack=null,d.prototype.onremovestream=null,d.prototype.onsignalingstatechange=null,d.prototype.oniceconnectionstatechange=null,d.prototype.onicegatheringstatechange=null,d.prototype.onnegotiationneeded=null,d.prototype.ondatachannel=null,d.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},d.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},d.prototype.getConfiguration=function(){return this._config},d.prototype.getLocalStreams=function(){return this.localStreams},d.prototype.getRemoteStreams=function(){return this.remoteStreams},d.prototype._createTransceiver=function(e){var t=this.transceivers.length>0,n={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};
1if(this.usingBundle&&t)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var r=this._createIceAndDtlsTransports();n.iceTransport=r.iceTransport,n.dtlsTransport=r.dtlsTransport}return this.transceivers.push(n),n},d.prototype.addTrack=function(t,n){if(this._isClosed)throw c("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");if(this.transceivers.find(function(e){return e.track===t}))throw c("InvalidAccessError","Track already exists.");for(var r,i=0;i<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(r=this.transceivers[i]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(n)&&this.localStreams.push(n),r.track=t,r.stream=n,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},d.prototype.addStream=function(e){var n=this;if(t>=15025)e.getTracks().forEach(function(t){n.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)})}},d.prototype.removeTrack=function(t){if(this._isClosed)throw c("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find(function(e){return e.rtpSender===t});if(!n)throw c("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null,-1===this.transceivers.map(function(e){return e.stream}).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},d.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var n=t.getSenders().find(function(t){return t.track===e});n&&t.removeTrack(n)})},d.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},d.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},d.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>
10)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},d.prototype._gather=function(t,n){var i=this,o=this.transceivers[n].iceGatherer;if(!o.onlocalcandidate){var a=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,o.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),o.onlocalcandidate=function(e){if(!i.usingBundle||!(n>0)){var a=new Event("icecandidate");a.candidate={sdpMid:t,sdpMLineIndex:n};var s=e.candidate,c=!s||0===Object.keys(s).length;if(c)("new"===o.state||"gathering"===o.state)&&(o.state="completed");else{"new"===o.state&&(o.state="gathering"),s.component=1;var u=r.writeCandidate(s);a.candidate=Object.assign(a.candidate,r.parseCandidate(u)),a.candidate.candidate=u}var d=r.getMediaSections(i.localDescription.sdp);c?d[a.candidate.sdpMLineIndex]+="a=end-of-candidates\r\n":d[a.candidate.sdpMLineIndex]+="a="+a.candidate.candidate+"\r\n",i.localDescription.sdp=r.getDescription(i.localDescription.sdp)+d.join("");var l=i.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),c||i._dispatchEvent("icecandidate",a),l&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout(function(){a.forEach(function(e){o.onlocalcandidate(e)})},0)}},d.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},d.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},d.prototype._transceive=function(e,n,i){var a=o(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(a.encodings=e.sendEncodingParameters,a.rtcp={cname:r.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(a.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(a)),i&&e.rtpReceiver&&a.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),e.recvEncodingParameters.length?a.encodings=e.recvEncodingParameters:a.encodings=[{}],a.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(a.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(a.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(a))},d.prototype.setLocalDescription=function(e){var t,n,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(c("TypeError",'Unsupported type "'+e.type+'"'));if(!a("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(c("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)n=(t=r.splitSections(e.sdp)).shift(),t.forEach(function(e,t){var n=r.parseRtpParameters(e);i.transceivers[t].localCapabilities=n}
1),i.transceivers.forEach(function(e,t){i._gather(e.mid,t)});else if("answer"===e.type){n=(t=r.splitSections(i.remoteDescription.sdp)).shift();var s=r.matchPrefix(n,"a=ice-lite").length>0;t.forEach(function(e,t){var a=i.transceivers[t],c=a.iceGatherer,u=a.iceTransport,d=a.dtlsTransport,l=a.localCapabilities,p=a.remoteCapabilities;if(!(r.isRejected(e)&&0===r.matchPrefix(e,"a=bundle-only").length)&&!a.isDatachannel){var f=r.getIceParameters(e,n),h=r.getDtlsParameters(e,n);s&&(h.role="server"),i.usingBundle&&0!==t||(i._gather(a.mid,t),"new"===u.state&&u.start(c,f,s?"controlling":"controlled"),"new"===d.state&&d.start(h));var m=o(l,p);i._transceive(a,m.codecs.length>0,!1)}})}return i.localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?i._updateSignalingState("have-local-offer"):i._updateSignalingState("stable"),Promise.resolve()},d.prototype.setRemoteDescription=function(i){var o=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(c("TypeError",'Unsupported type "'+i.type+'"'));if(!a("setRemoteDescription",i.type,o.signalingState)||o._isClosed)return Promise.reject(c("InvalidStateError","Can not set remote "+i.type+" in state "+o.signalingState));var d={};o.remoteStreams.forEach(function(e){d[e.id]=e});var l=[],p=r.splitSections(i.sdp),f=p.shift(),h=r.matchPrefix(f,"a=ice-lite").length>0,m=r.matchPrefix(f,"a=group:BUNDLE ").length>0;o.usingBundle=m;var g=r.matchPrefix(f,"a=ice-options:")[0];return g?o.canTrickleIceCandidates=g.substr(14).split(" ").indexOf("trickle")>=0:o.canTrickleIceCandidates=!1,p.forEach(function(a,c){var u=r.splitLines(a),p=r.getKind(a),g=r.isRejected(a)&&0===r.matchPrefix(a,"a=bundle-only").length,v=u[0].substr(2).split(" ")[2],_=r.getDirection(a,f),y=r.parseMsid(a),b=r.getMid(a)||r.generateIdentifier();if("application"===p&&"DTLS/SCTP"===v){o.transceivers[c]={mid:b,isDatachannel:!0};return}var S=r.parseRtpParameters(a);g||(M=r.getIceParameters(a,f),(j=r.getDtlsParameters(a,f)).role="client"),O=r.parseRtpEncodingParameters(a);var w=r.parseRtcpParameters(a),E=r.matchPrefix(a,"a=end-of-candidates",f).length>0,C=r.matchPrefix(a,"a=candidate:").map(function(e){return r.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===i.type||"answer"===i.type)&&!g&&m&&c>0&&o.transceivers[c]&&(o._disposeIceAndDtlsTransports(c),o.transceivers[c].iceGatherer=o.transceivers[
10].iceGatherer,o.transceivers[c].iceTransport=o.transceivers[0].iceTransport,o.transceivers[c].dtlsTransport=o.transceivers[0].dtlsTransport,o.transceivers[c].rtpSender&&o.transceivers[c].rtpSender.setTransport(o.transceivers[0].dtlsTransport),o.transceivers[c].rtpReceiver&&o.transceivers[c].rtpReceiver.setTransport(o.transceivers[0].dtlsTransport)),"offer"!==i.type||g)"answer"!==i.type||g||(T=(P=o.transceivers[c]).iceGatherer,I=P.iceTransport,k=P.dtlsTransport,x=P.rtpReceiver,R=P.sendEncodingParameters,A=P.localCapabilities,o.transceivers[c].recvEncodingParameters=O,o.transceivers[c].remoteCapabilities=S,o.transceivers[c].rtcpParameters=w,C.length&&"new"===I.state&&((h||E)&&(!m||0===c)?I.setRemoteCandidates(C):C.forEach(function(e){s(P.iceTransport,e)})),m&&0!==c||("new"===I.state&&I.start(T,M,"controlling"),"new"===k.state&&k.start(j)),o._transceive(P,"sendrecv"===_||"recvonly"===_,"sendrecv"===_||"sendonly"===_),x&&("sendrecv"===_||"sendonly"===_)?(D=x.track,y?(d[y.stream]||(d[y.stream]=new e.MediaStream),n(D,d[y.stream]),l.push([D,x,d[y.stream]])):(d.default||(d.default=new e.MediaStream),n(D,d.default),l.push([D,x,d.default]))):delete P.rtpReceiver);else{(P=o.transceivers[c]||o._createTransceiver(p)).mid=b,P.iceGatherer||(P.iceGatherer=o._createIceGatherer(c,m)),C.length&&"new"===P.iceTransport.state&&(E&&(!m||0===c)?P.iceTransport.setRemoteCandidates(C):C.forEach(function(e){s(P.iceTransport,e)})),A=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(A.codecs=A.codecs.filter(function(e){return"rtx"!==e.name})),R=P.sendEncodingParameters||[{ssrc:(2*c+2)*1001}];var P,T,I,k,x,R,O,A,D,M,j,L,N=!1;"sendrecv"===_||"sendonly"===_?(N=!P.rtpReceiver,x=P.rtpReceiver||new e.RTCRtpReceiver(P.dtlsTransport,p),N&&(D=x.track,y&&"-"===y.stream||(y?(d[y.stream]||(d[y.stream]=new e.MediaStream,Object.defineProperty(d[y.stream],"id",{get:function(){return y.stream}})),Object.defineProperty(D,"id",{get:function(){return y.track}}),L=d[y.stream]):(d.default||(d.default=new e.MediaStream),L=d.default)),L&&(n(D,L),P.associatedRemoteMediaStreams.push(L)),l.push([D,x,L]))):P.rtpReceiver&&P.rtpReceiver.track&&(P.associatedRemoteMediaStreams.forEach(function(t){var n=t.getTracks().find(function(e){return e.id===P.rtpReceiver.track.id});n&&(t.removeTrack(n),t.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:n})))}),P.associatedRemoteMediaStreams=[]),P.localCapabilities=A,P.remoteCapabilities=S,P.rtpReceiver=x,P.rtcpParameters=w,P.sendEncodingParameters=R,P.recvEncodingParameters=O,o._transceive(o.transceivers[c],!1,N)}}),void 0===o._dtlsRole&&(o._dtlsRole="offer"===i.type?"active":"passive"),o.remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?o._updateSignalingState("have-remote-offer"):o._updateSignalingState("stable"),Object.keys(d).forEach(function(t){var n=d[t];if(n.getTracks().length){if(-1===o.remoteStreams.indexOf(n)){o.remoteStreams.push(n);var r=new Event("addstream");r.stream=n,e.setTimeout(function(){o._dispatchEvent("addstream",r)})}l.forEach(function(e){var t=e[0],r=e[1];n.id===e[2].id&&u(o,t,r,[n])})}}),l.forEach(function(e){e[2]||u(o,e[0],e[1],[])}),e.setTimeout(function(){o&&o.transceivers&&o.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},d.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},d.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},d.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0))},d.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};
1if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++,t[e.dtlsTransport.state]++}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0||t.checking>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":(t.connected>0||t.completed>0)&&(e="connected"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},d.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(c("InvalidStateError","Can not call createOffer after close"));var o=n.transceivers.filter(function(e){return"audio"===e.kind}).length,a=n.transceivers.filter(function(e){return"video"===e.kind}).length,s=arguments[0];if(s){if(s.mandatory||s.optional)throw TypeError("Legacy mandatory/optional constraints not supported.");void 0!==s.offerToReceiveAudio&&(o=!0===s.offerToReceiveAudio?1:!1===s.offerToReceiveAudio?0:s.offerToReceiveAudio),void 0!==s.offerToReceiveVideo&&(a=!0===s.offerToReceiveVideo?1:!1===s.offerToReceiveVideo?0:s.offerToReceiveVideo)}for(n.transceivers.forEach(function(e){"audio"===e.kind?--o<0&&(e.wantReceive=!1):"video"===e.kind&&--a<0&&(e.wantReceive=!1)});o>0||a>0;)o>0&&(n._createTransceiver("audio"),o--),a>0&&(n._createTransceiver("video"),a--);var u=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);return n.transceivers.forEach(function(i,o){var a=i.track,s=i.kind,c=i.mid||r.generateIdentifier();i.mid=c,i.iceGatherer||(i.iceGatherer=n._createIceGatherer(o,n.usingBundle));var u=e.RTCRtpSender.getCapabilities(s);t<15019&&(u.codecs=u.codecs.filter(function(e){return"rtx"!==e.name})),u.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach(function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)})}),u.headerExtensions.forEach(function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach(function(t){e.uri===t.uri&&(e.id=t.id)})});var d=i.sendEncodingParameters||[{ssrc:(2*o+1)*1001}];a&&t>=15019&&"video"===s&&!d[0].rtx&&(d[0].rtx={ssrc:d[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,s)),i.localCapabilities=u,i.sendEncodingParameters=d}),"max-compat"!==n._config.bundlePolicy&&(u+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",n.transceivers.forEach(function(e,t){u+=i(e,e.localCapabilities,"offer",e.stream,n._dtlsRole)+"a=rtcp-rsize\r\n",e.iceGatherer&&"new"!==n.iceGatheringState&&(0===t||!n.usingBundle)&&(e.iceGatherer.getLocalCandidates().forEac
1h(function(e){e.component=1,u+="a="+r.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))}),Promise.resolve(new e.RTCSessionDescription({type:"offer",sdp:u}))},d.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(c("InvalidStateError","Can not call createAnswer after close"));var a=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(a+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n");var s=r.getMediaSections(n.remoteDescription.sdp).length;return n.transceivers.forEach(function(e,r){if(!(r+1>s)){if(e.isDatachannel){a+="m=application 0 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=mid:"+e.mid+"\r\n";return}if(e.stream){var c;"audio"===e.kind?c=e.stream.getAudioTracks()[0]:"video"===e.kind&&(c=e.stream.getVideoTracks()[0]),c&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1})}var u=o(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,a+=i(e,u,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(a+="a=rtcp-rsize\r\n")}}),Promise.resolve(new e.RTCSessionDescription({type:"answer",sdp:a}))},d.prototype.addIceCandidate=function(e){var t,n=this;return e&&!(void 0!==e.sdpMLineIndex||e.sdpMid)?Promise.reject(TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(i,o){if(!n.remoteDescription)return o(c("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var a=e.sdpMLineIndex;if(e.sdpMid){for(var u=0;u<n.transceivers.length;u++)if(n.transceivers[u].mid===e.sdpMid){a=u;break}}var d=n.transceivers[a];if(!d)return o(c("OperationError","Can not add ICE candidate"));if(d.isDatachannel)return i();var l=Object.keys(e.candidate).length>0?r.parseCandidate(e.candidate):{};if("tcp"===l.protocol&&(0===l.port||9===l.port)||l.component&&1!==l.component)return i();if((0===a||a>
10&&d.iceTransport!==n.transceivers[0].iceTransport)&&!s(d.iceTransport,l))return o(c("OperationError","Can not add ICE candidate"));var p=e.candidate.trim();0===p.indexOf("a=")&&(p=p.substr(2)),t=r.getMediaSections(n.remoteDescription.sdp),t[a]+="a="+(l.type?p:"end-of-candidates")+"\r\n",n.remoteDescription.sdp=t.join("")}else for(var f=0;f<n.transceivers.length&&(n.transceivers[f].isDatachannel||(n.transceivers[f].iceTransport.addRemoteCandidate({}),t=r.getMediaSections(n.remoteDescription.sdp),t[f]+="a=end-of-candidates\r\n",n.remoteDescription.sdp=r.getDescription(n.remoteDescription.sdp)+t.join(""),!n.usingBundle));f++);i()})},d.prototype.getStats=function(){var e=[];return this.transceivers.forEach(function(t){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(n){t[n]&&e.push(t[n].getStats())})}),new Promise(function(t){var n=new Map;Promise.all(e).then(function(e){e.forEach(function(e){Object.keys(e).forEach(function(t){var r;e[t].type=({inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"})[(r=e[t]).type]||r.type,n.set(t,e[t])})}),t(n)})})};var l=["createOffer","createAnswer"];return l.forEach(function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then(function(t){"function"==typeof e[0]&&e[0].apply(null,[t])},function(t){"function"==typeof e[1]&&e[1].apply(null,[t])}):t.apply(this,arguments)}}),(l=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)},function(t){"function"==typeof e[2]&&e[2].apply(null,[t])}):t.apply(this,arguments)}}),["getStats"].forEach(function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)}):t.apply(this,arguments)}}),d}},40802:function(e){"use strict";var t={};t.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},t.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},t.getDescription=function(e){var n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){var n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter(function(e){return 0===e.indexOf(n)})},t.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:n[t[r]]=t[r+1]}return n},t.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.pu
vendor: 4,354 bytes, line 1
1sh(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},t.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},t.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach(function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)}),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},t.getMid=function(e){var n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){var r=t.matchPrefix(e+n,"a=ice-ufrag:")[0],i=t.matchPrefix(e+n,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},t.parseRtpParameters=function(e){for(var n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" "),i=3;i<r.length;i++){var o=r[i],a=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(a){var s=t.parseRtpMap(a),c=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(s.parameters=c.length?t.parseFmtp(c[0]):{},s.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),n.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(s.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach(function(e){n.headerExtensions.push(t.parseExtmap(e))}),n},t.writeRtpDescription=function(e,n){var r="";
1r+="m="+e+" "+(n.codecs.length>0?"9":"0")+" UDP/TLS/RTP/SAVPF "+n.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach(function(e){r+=t.writeRtpMap(e)+t.writeFmtp(e)+t.writeRtcpFb(e)});var i=0;return n.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",n.headerExtensions&&n.headerExtensions.forEach(function(e){r+=t.writeExtmap(e)}),r},t.parseRtpEncodingParameters=function(e){var n,r=[],i=t.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map(function(e){return t.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=s.length>0&&s[0].ssrc,u=t.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});u.length>0&&u[0].length>1&&u[0][0]===c&&(n=u[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&n&&(t.rtx={ssrc:n}),r.push(t),o&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},r.push(t))}}),0===r.length&&c&&r.push({ssrc:c});var d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?950*parseInt(d[0].substr(5),10)-16e3:void 0,r.forEach(function(e){e.maxBitrate=d})),r},t.parseRtcpParameters=function(e){var n={},r=t.matchPrefix(e,"a=ssrc:").map(function(e){return t.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);var i=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=i.length>0,n.compound=0===i.length;var o=t.matchPrefix(e,"a=rtcp-mux");return n.mux=o.length>0,n},t.parseMsid=function(e){var n,r=t.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(n=r[0].substr(7).split(" "))[0],track:n[1]};var i=t.matchPrefix(e,"a=ssrc:").map(function(e){return t.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});if(i.length>0)return{stream:(n=i[0].value.split(" "))[0],track:n[1]}},t.parseSctpDescription=function(e){var n,r=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");i.length>0&&(n=parseInt(i[0].substr(19),10)),isNaN(n)&&(n=65536);var o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:r.fmt,maxMessageSize:n};if(t.matchPrefix(e,"a=sctpmap:").length>0){var a=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:n}}},t.writeSctpDescription=function(e,t){var n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,n,r){return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+(void 0!==n?n:2)+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,n,r,i){var o=t.writeRtpDescription(e.kind,n);if(o+=t.writeIceParameters(e.iceGatherer.getLocalParameters())+t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active")+"a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var a="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+a+("a=ssrc:"+e.sendEncodingParameters[0].ssrc)+" "+a,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a+("a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" ")+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+"\r\n"),o},t.getDirection=function(e,n){for(var r=t.splitLines(e),i=0;i<r.length;i++)switch(r[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[i].substr(2)}return n?t.getDirection(n):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var n=t.splitLines(e)[0].substr(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){var n=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var n=t.splitLines(e),r=0;r<n.length;r++)if(n[r].length<2||"="!==n[r].charAt(1))return!1;return!0},e.exports=t}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.