@moveo-ai/web-client 0.108.0 → 0.109.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +164 -69
- package/dist/63.min.js +2 -0
- package/dist/{329.min.js.LICENSE.txt → 63.min.js.LICENSE.txt} +1 -1
- package/dist/752.min.js +2 -0
- package/dist/{147.min.js.LICENSE.txt → 752.min.js.LICENSE.txt} +1 -1
- package/dist/882.min.js +1 -1
- package/dist/882.min.js.LICENSE.txt +1 -1
- package/dist/929.min.js +1 -1
- package/dist/929.min.js.LICENSE.txt +1 -1
- package/dist/audio-client.min.js +1 -1
- package/dist/audio-client.min.js.LICENSE.txt +20 -10
- package/dist/iframe.min.js +1 -1
- package/dist/iframe.min.js.LICENSE.txt +24 -27
- package/dist/index.html +1 -7
- package/dist/preview/index.html +16 -14
- package/dist/preview-telnyx/index.html +79 -0
- package/dist/preview.css.min.js +1 -1
- package/dist/preview.css.min.js.LICENSE.txt +1 -1
- package/dist/telnyx-client.min.js +1 -1
- package/dist/telnyx-client.min.js.LICENSE.txt +20 -10
- package/dist/web-client.min.js +1 -1
- package/dist/web-client.min.js.LICENSE.txt +1 -1
- package/dist/webrtc-client.min.js +1 -1
- package/dist/webrtc-client.min.js.LICENSE.txt +20 -10
- package/package.json +108 -99
- package/web-client.d.ts +152 -0
- package/dist/147.min.js +0 -2
- package/dist/147.min.js.map +0 -1
- package/dist/329.min.js +0 -2
- package/dist/329.min.js.map +0 -1
- package/dist/882.min.js.map +0 -1
- package/dist/929.min.js.map +0 -1
- package/dist/954.min.js +0 -2
- package/dist/954.min.js.LICENSE.txt +0 -6
- package/dist/954.min.js.map +0 -1
- package/dist/audio-client.min.js.map +0 -1
- package/dist/iframe.min.js.map +0 -1
- package/dist/iframe.v2.min.js +0 -2
- package/dist/iframe.v2.min.js.LICENSE.txt +0 -63
- package/dist/iframe.v2.min.js.map +0 -1
- package/dist/preview.css.min.js.map +0 -1
- package/dist/telnyx-client.min.js.map +0 -1
- package/dist/web-client.min.js.map +0 -1
- package/dist/webrtc-client.min.js.map +0 -1
package/dist/752.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 752.min.js.LICENSE.txt */
|
|
2
|
+
"use strict";(this.webpackChunkMoveoAI||=[]).push([[752],{7963(e){const t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map(e=>e.trim())},t.splitSections=function(e){return e.split("\nm=").map((e,t)=>(t>0?"m="+e:e).trim()+"\r\n")},t.getDescription=function(e){const r=t.splitSections(e);return r&&r[0]},t.getMediaSections=function(e){const r=t.splitSections(e);return r.shift(),r},t.matchPrefix=function(e,r){return t.splitLines(e).filter(e=>0===e.indexOf(r))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const r={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let e=8;e<t.length;e+=2)switch(t[e]){case"raddr":r.relatedAddress=t[e+1];break;case"rport":r.relatedPort=parseInt(t[e+1],10);break;case"tcptype":r.tcpType=t[e+1];break;case"ufrag":r.ufrag=t[e+1],r.usernameFragment=t[e+1];break;default:void 0===r[t[e]]&&(r[t[e]]=t[e+1])}return r},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const r=e.component;"rtp"===r?t.push(1):"rtcp"===r?t.push(2):t.push(r),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&void 0!==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.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){let t=e.substring(9).split(" ");const r={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=parseInt(t[1],10),r.channels=3===t.length?parseInt(t[2],10):1,r.numChannels=r.channels,r},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){const t={};let r;const n=e.substring(e.indexOf(" ")+1).split(";");for(let e=0;e<n.length;e++)r=n[e].trim().split("="),t[r[0].trim()]=r[1];return t},t.writeFmtp=function(e){let t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const n=[];Object.keys(e.parameters).forEach(t=>{void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)}),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(e=>{t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),r={ssrc:parseInt(e.substring(7,t),10)},n=e.indexOf(":",t);return n>-1?(r.attribute=e.substring(t+1,n),r.value=e.substring(n+1)):r.attribute=e.substring(t+1),r},t.parseSsrcGroup=function(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(e=>parseInt(e,10))}},t.getMid=function(e){const r=t.matchPrefix(e,"a=mid:")[0];if(r)return r.substring(6)},t.parseFingerprint=function(e){const t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,r){return{role:"auto",fingerprints:t.matchPrefix(e+r,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let r="a=setup:"+t+"\r\n";return e.fingerprints.forEach(e=>{r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),r},t.parseCryptoLine=function(e){const t=e.substring(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;const t=e.substring(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,r){return t.matchPrefix(e+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,r){const n=t.matchPrefix(e+r,"a=ice-ufrag:")[0],i=t.matchPrefix(e+r,"a=ice-pwd:")[0];return n&&i?{usernameFragment:n.substring(12),password:i.substring(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e)[0].split(" ");r.profile=n[2];for(let i=3;i<n.length;i++){const o=n[i],s=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(s){const n=t.parseRtpMap(s),i=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(n.parameters=i.length?t.parseFmtp(i[0]):{},n.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),r.codecs.push(n),n.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(n.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach(e=>{r.headerExtensions.push(t.parseExtmap(e))});const i=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return r.codecs.forEach(e=>{i.forEach(t=>{e.rtcpFeedback.find(e=>e.type===t.type&&e.parameter===t.parameter)||e.rtcpFeedback.push(t)})}),r},t.writeRtpDescription=function(e,r){let n="";n+="m="+e+" ",n+=r.codecs.length>0?"9":"0",n+=" "+(r.profile||"UDP/TLS/RTP/SAVPF")+" ",n+=r.codecs.map(e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",r.codecs.forEach(e=>{n+=t.writeRtpMap(e),n+=t.writeFmtp(e),n+=t.writeRtcpFb(e)});let i=0;return r.codecs.forEach(e=>{e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),r.headerExtensions&&r.headerExtensions.forEach(e=>{n+=t.writeExtmap(e)}),n},t.parseRtpEncodingParameters=function(e){const r=[],n=t.parseRtpParameters(e),i=-1!==n.fecMechanisms.indexOf("RED"),o=-1!==n.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map(e=>t.parseSsrcMedia(e)).filter(e=>"cname"===e.attribute),a=s.length>0&&s[0].ssrc;let c;const p=t.matchPrefix(e,"a=ssrc-group:FID").map(e=>e.substring(17).split(" ").map(e=>parseInt(e,10)));p.length>0&&p[0].length>1&&p[0][0]===a&&(c=p[0][1]),n.codecs.forEach(e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:a,codecPayloadType:parseInt(e.parameters.apt,10)};a&&c&&(t.rtx={ssrc:c}),r.push(t),i&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:a,mechanism:o?"red+ulpfec":"red"},r.push(t))}}),0===r.length&&a&&r.push({ssrc:a});let d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substring(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substring(5),10)*.95-16e3:void 0,r.forEach(e=>{e.maxBitrate=d})),r},t.parseRtcpParameters=function(e){const r={},n=t.matchPrefix(e,"a=ssrc:").map(e=>t.parseSsrcMedia(e)).filter(e=>"cname"===e.attribute)[0];n&&(r.cname=n.value,r.ssrc=n.ssrc);const i=t.matchPrefix(e,"a=rtcp-rsize");r.reducedSize=i.length>0,r.compound=0===i.length;const o=t.matchPrefix(e,"a=rtcp-mux");return r.mux=o.length>0,r},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let r;const n=t.matchPrefix(e,"a=msid:");if(1===n.length)return r=n[0].substring(7).split(" "),{stream:r[0],track:r[1]};const i=t.matchPrefix(e,"a=ssrc:").map(e=>t.parseSsrcMedia(e)).filter(e=>"msid"===e.attribute);return i.length>0?(r=i[0].value.split(" "),{stream:r[0],track:r[1]}):void 0},t.parseSctpDescription=function(e){const r=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:");let i;n.length>0&&(i=parseInt(n[0].substring(19),10)),isNaN(i)&&(i=65536);const o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:r.fmt,maxMessageSize:i};const s=t.matchPrefix(e,"a=sctpmap:");if(s.length>0){const e=s[0].substring(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:i}}},t.writeSctpDescription=function(e,t){let r=[];return r="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&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,r,n){let i;const o=void 0!==r?r:2;return i=e||t.generateSessionId(),"v=0\r\no="+(n||"thisisadapterortc")+" "+i+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,r){const n=t.splitLines(e);for(let e=0;e<n.length;e++)switch(n[e]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[e].substring(2)}return r?t.getDirection(r):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const r=t.splitLines(e)[0].substring(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},t.parseOLine=function(e){const r=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const r=t.splitLines(e);for(let e=0;e<r.length;e++)if(r[e].length<2||"="!==r[e].charAt(1))return!1;return!0},e.exports=t},6752(e,t,r){(0,r(8525).a)({window:"undefined"==typeof window?void 0:window})},8525(e,t,r){r.d(t,{a:()=>f});var n=r(2634),i=r(6528),o=r(6542),s=r(5176),a=r(2824),c=r(7016),p=r(7963),d={};r.r(d),r.d(d,{fixNegotiationNeeded:()=>i.I5,shimAddTrackRemoveTrack:()=>i.T3,shimAddTrackRemoveTrackWithNative:()=>i.Eo,shimGetSendersWithDtmf:()=>i.Lh,shimGetUserMedia:()=>i.ZS,shimMediaStream:()=>i.y2,shimOnTrack:()=>i.KM,shimPeerConnection:()=>i._y,shimSenderReceiverGetStats:()=>i.XG});var h={};r.r(h),r.d(h,{shimAddTransceiver:()=>o.Zd,shimCreateAnswer:()=>o.er,shimCreateOffer:()=>o.eV,shimGetDisplayMedia:()=>o.af,shimGetParameters:()=>o.qS,shimGetStats:()=>o.ZF,shimGetUserMedia:()=>o.ZS,shimOnTrack:()=>o.KM,shimPeerConnection:()=>o._y,shimRTCDataChannel:()=>o.se,shimReceiverGetStats:()=>o.kw,shimRemoveStream:()=>o.uY,shimSenderGetStats:()=>o.mD});var u={};r.r(u),r.d(u,{shimAudioContext:()=>a.do,shimCallbacksAPI:()=>a.Qr,shimConstraints:()=>a.En,shimCreateOfferLegacy:()=>a.hQ,shimGetUserMedia:()=>a.ZS,shimLocalStreamsAPI:()=>a._M,shimRTCIceServerUrls:()=>a.j2,shimRemoteStreamsAPI:()=>a.Hz,shimTrackEventTransceiver:()=>a.n3});var m={};function f({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimSafari:!0}){const r=n.Rm,f=n.cO(e),l={browserDetails:f,commonShim:m,extractVersion:n.Gr,disableLog:n.Rn,disableWarnings:n.co,sdp:p};switch(f.browser){case"chrome":if(!d||!i._y||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),l;if(null===f.version)return r("Chrome shim can not determine version, not shimming."),l;r("adapter.js shimming chrome."),l.browserShim=d,c.iA(e,f),c.f3(e,f),i.ZS(e,f),i.y2(e,f),i._y(e,f),i.KM(e,f),i.T3(e,f),i.Lh(e,f),i.XG(e,f),i.I5(e,f),c.BX(e,f),c.Ih(e,f),c.zP(e,f),c.qo(e,f),c.S2(e,f),c.CD(e,f);break;case"firefox":if(!h||!o._y||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),l;r("adapter.js shimming firefox."),l.browserShim=h,c.iA(e,f),c.f3(e,f),s.Z(e,f),o._y(e,f),o.ZF(e,f),o.KM(e,f),o.uY(e,f),o.mD(e,f),o.kw(e,f),o.se(e,f),o.Zd(e,f),o.qS(e,f),o.eV(e,f),o.er(e,f),c.BX(e,f),c.zP(e,f),c.qo(e,f),c.S2(e,f);break;case"safari":if(!u||!t.shimSafari)return r("Safari shim is not included in this adapter release."),l;r("adapter.js shimming safari."),l.browserShim=u,c.iA(e,f),c.f3(e,f),a.j2(e,f),a.hQ(e,f),a.Qr(e,f),a._M(e,f),a.Hz(e,f),a.n3(e,f),a.ZS(e,f),a.do(e,f),c.BX(e,f),c.Ih(e,f),c.qo(e,f),c.S2(e,f),c.CD(e,f);break;default:r("Unsupported browser!")}return l}r.r(m),r.d(m,{removeExtmapAllowMixed:()=>c.CD,shimAddIceCandidateNullOrEmpty:()=>c.iA,shimConnectionState:()=>c.zP,shimMaxMessageSize:()=>c.qo,shimParameterlessSetLocalDescription:()=>c.f3,shimRTCIceCandidate:()=>c.BX,shimRTCIceCandidateRelayProtocol:()=>c.Ih,shimSendThrowTypeError:()=>c.S2})},6528(e,t,r){r.r(t),r.d(t,{Eo:()=>p,I5:()=>u,KM:()=>s,Lh:()=>a,T3:()=>d,XG:()=>c,ZS:()=>i.Z,_y:()=>h,y2:()=>o});var n=r(2634),i=r(1293);function o(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function s(e,t){if(!(t.version>102))if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===r.track.id):{track:r.track};const i=new Event("track");i.track=r.track,i.receiver=n,i.transceiver={receiver:n},i.streams=[t.stream],this.dispatchEvent(i)}),t.stream.getTracks().forEach(r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===r.id):{track:r};const i=new Event("track");i.track=r,i.receiver=n,i.transceiver={receiver:n},i.streams=[t.stream],this.dispatchEvent(i)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else n.V1(e,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function a(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){let i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach(e=>{this._senders.push(t(this,e))})};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach(e=>{const t=this._senders.find(t=>t.track===e);t&&this._senders.splice(this._senders.indexOf(t),1)})}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function c(e,t){if(t.version>=67)return;if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>n.sc(t,e.track,!0))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),n.V1(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>n.sc(t,e.track,!1))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,r,n;return this.getSenders().forEach(r=>{r.track===e&&(t?n=!0:t=r)}),this.getReceivers().forEach(t=>(t.track===e&&(r?n=!0:r=t),t.track===e)),n||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return r.apply(this,arguments)}}function p(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(e=>this._shimmedLocalStreams[e][0])};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")});const t=this.getSenders();r.apply(this,arguments);const n=this.getSenders().filter(e=>-1===t.indexOf(e));this._shimmedLocalStreams[e.id]=[e].concat(n)};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(t=>{const r=this._shimmedLocalStreams[t].indexOf(e);-1!==r&&this._shimmedLocalStreams[t].splice(r,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]}),i.apply(this,arguments)}}function d(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return p(e);const r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=r.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map(e=>this._reverseStreams[e.id])};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){const r=new e.MediaStream(t.getTracks());this._streams[t.id]=r,this._reverseStreams[r.id]=t,t=r}n.apply(this,[t])};const i=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)}),new RTCSessionDescription({type:t.type,sdp:r})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,r){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find(e=>e===t))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(e=>e.track===t))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const i=this._streams[r.id];if(i)i.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const n=new e.MediaStream([t]);this._streams[r.id]=n,this._reverseStreams[n.id]=r,this.addStream(n)}return this.getSenders().find(e=>e.track===t)},["createOffer","createAnswer"].forEach(function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(this,[t=>{const r=o(this,t);e[0].apply(null,[r])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):r.apply(this,arguments).then(e=>o(this,e))}};e.RTCPeerConnection.prototype[t]=n[t]});const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:r})}(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=a.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach(r=>{this._streams[r].getTracks().find(t=>e.track===t)&&(t=this._streams[r])}),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function h(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]})}function u(e,t){t.version>102||n.V1(e,"negotiationneeded",e=>{const r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e})}},1293(e,t,r){r.d(t,{Z:()=>i});const n=r(2634).Rm;function i(e,t){if(t.version>=64)return;const r=e&&e.navigator;if(!r.mediaDevices)return;const i=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const n="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[i("min",r)]=n.ideal,t.optional.push(e),e={},e[i("max",r)]=n.ideal,t.optional.push(e)):(e[i("",r)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach(e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},o=function(e,o){if(t.version>=61)return o(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=i(e.audio)}if(e&&"object"==typeof e.video){let s=e.video.facingMode;s=s&&("object"==typeof s?s:{ideal:s});const a=t.version<66;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||a)){let t;if(delete e.video.facingMode,"environment"===s.exact||"environment"===s.ideal?t=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(t=["front"]),t)return r.mediaDevices.enumerateDevices().then(r=>{let a=(r=r.filter(e=>"videoinput"===e.kind)).find(e=>t.some(t=>e.label.toLowerCase().includes(t)));return!a&&r.length&&t.includes("back")&&(a=r[r.length-1]),a&&(e.video.deviceId=s.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=i(e.video),n("chrome: "+JSON.stringify(e)),o(e)})}e.video=i(e.video)}return n("chrome: "+JSON.stringify(e)),o(e)},s=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,n){o(e,e=>{r.webkitGetUserMedia(e,t,e=>{n&&n(s(e))})})}.bind(r),r.mediaDevices.getUserMedia){const e=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(t){return o(t,t=>e(t).then(e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(e=>{e.stop()}),new DOMException("","NotFoundError");return e},e=>Promise.reject(s(e))))}}}},7016(e,t,r){r.r(t),r.d(t,{BX:()=>s,CD:()=>h,Ih:()=>a,S2:()=>p,f3:()=>m,iA:()=>u,qo:()=>c,zP:()=>d});var n=r(7963),i=r.n(n),o=r(2634);function s(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substring(2)),e.candidate&&e.candidate.length){const r=new t(e),n=i().parseCandidate(e.candidate);for(const e in n)e in r||Object.defineProperty(r,e,{value:n[e]});return r.toJSON=function(){return{candidate:r.candidate,sdpMid:r.sdpMid,sdpMLineIndex:r.sdpMLineIndex,usernameFragment:r.usernameFragment}},r}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,o.V1(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function a(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||o.V1(e,"icecandidate",e=>{if(e.candidate){const t=i().parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e})}function c(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>102)return;if("firefox"===t.browser&&t.version>=113)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=i().splitSections(e.sdp);return t.shift(),t.some(e=>{const t=i().parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const r=parseInt(t[1],10);return r!=r?-1:r}(arguments[0]),r=function(e){let r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r}(e),n=function(e,r){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const o=i().matchPrefix(e.sdp,"a=max-message-size:");return o.length>0?n=parseInt(o[0].substring(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n}(arguments[0],e);let o;o=0===r&&0===n?Number.POSITIVE_INFINITY:0===r||0===n?Math.max(r,n):Math.min(r,n);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>o}),this._sctp=s}return r.apply(this,arguments)}}function p(e,t){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;if("chrome"===t.browser&&t.version>=149)return;if("firefox"===t.browser&&t.version>60)return;function r(e,t){const r=e.send;e.send=function(){const n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}const n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=n.apply(this,arguments);return r(e,this),e},o.V1(e,"datachannel",e=>(r(e.channel,e.target),e))}function d(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function h(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t._safariVersion>=13.1)return;const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const r=t.sdp.split("\n").filter(e=>"a=extmap-allow-mixed"!==e.trim()).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:r}):t.sdp=r}return r.apply(this,arguments)}}function u(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function m(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return r.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}return e.sdp||"offer"!==e.type&&"answer"!==e.type?r.apply(this,[e]):("offer"===e.type?this.createOffer:this.createAnswer).apply(this).then(e=>r.apply(this,[e]))})}},6542(e,t,r){r.r(t),r.d(t,{KM:()=>s,ZF:()=>c,ZS:()=>i.Z,Zd:()=>m,_y:()=>a,af:()=>o.a,eV:()=>l,er:()=>C,kw:()=>d,mD:()=>p,qS:()=>f,se:()=>u,uY:()=>h});var n=r(2634),i=r(5176),o=r(2187);function s(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function a(e,t){"object"==typeof e&&(e.RTCPeerConnection||e.mozRTCPeerConnection)&&(!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}))}function c(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;if(t.version>=151)return;const r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,o]=arguments;return"closed"===this.signalingState?Promise.resolve(new Map):n.apply(this,[e||null]).then(e=>{if(t.version<53&&!i)try{e.forEach(e=>{e.type=r[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach((t,n)=>{e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))})}return e}).then(i,o)}}function p(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function d(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),n.V1(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function h(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){n.io("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function u(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function m(e,t){if("object"!=typeof e||!e.RTCPeerConnection)return;if(t.version>=110)return;const r=e.RTCPeerConnection.prototype.addTransceiver;r&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]),e=[...e];const t=e.length>0;t&&e.forEach(e=>{if("rid"in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const n=r.apply(this,arguments);if(t){const{sender:t}=n,r=t.getParameters();(!("encodings"in r)||1===r.encodings.length&&0===Object.keys(r.encodings[0]).length)&&(r.encodings=e,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(r).then(()=>{delete t.sendEncodings}).catch(()=>{delete t.sendEncodings})))}return n})}function f(e,t){if("object"!=typeof e||!e.RTCRtpSender)return;if(t.version>=110)return;const r=e.RTCRtpSender.prototype.getParameters;r&&(e.RTCRtpSender.prototype.getParameters=function(){const e=r.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function l(e,t){if("object"!=typeof e||!e.RTCPeerConnection)return;if(t.version>=110)return;const r=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>r.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):r.apply(this,arguments)}}function C(e,t){if("object"!=typeof e||!e.RTCPeerConnection)return;if(t.version>=110)return;const r=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>r.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):r.apply(this,arguments)}}},2187(e,t,r){function n(e,t){e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)}))}r.d(t,{a:()=>n})},5176(e,t,r){r.d(t,{Z:()=>i});var n=r(2634);function i(e,t){const r=e&&e.navigator;if(!r.mediaDevices)return;const i=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,i){n.io("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,i)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){const e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},t=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(r){return"object"==typeof r&&"object"==typeof r.audio&&(r=JSON.parse(JSON.stringify(r)),e(r.audio,"autoGainControl","mozAutoGainControl"),e(r.audio,"noiseSuppression","mozNoiseSuppression")),t(r)},i&&i.prototype.getSettings){const t=i.prototype.getSettings;i.prototype.getSettings=function(){const r=t.apply(this,arguments);return e(r,"mozAutoGainControl","autoGainControl"),e(r,"mozNoiseSuppression","noiseSuppression"),r}}if(i&&i.prototype.applyConstraints){const t=i.prototype.applyConstraints;i.prototype.applyConstraints=function(r){return"audio"===this.kind&&"object"==typeof r&&(r=JSON.parse(JSON.stringify(r)),e(r,"autoGainControl","mozAutoGainControl"),e(r,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[r])}}}}},2824(e,t,r){r.r(t),r.d(t,{En:()=>c,Hz:()=>o,Qr:()=>s,ZS:()=>a,_M:()=>i,do:()=>u,hQ:()=>h,j2:()=>p,n3:()=>d});var n=r(2634);function i(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(r=>t.call(this,r,e)),e.getVideoTracks().forEach(r=>t.call(this,r,e))},e.RTCPeerConnection.prototype.addTrack=function(e,...r){return r&&r.forEach(e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]}),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const r=e.getTracks();this.getSenders().forEach(e=>{r.includes(e.track)&&this.removeTrack(e)})})}}function o(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach(e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)})})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const r=new Event("addstream");r.stream=t,e.dispatchEvent(r)})}),t.apply(e,arguments)}}}function s(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i};let a=function(e,t,r){const n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=a,a=function(e,t,r){const n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=a,a=function(e,t,r){const n=s.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=a}function a(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,r=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>r(c(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function c(e){return e&&void 0!==e.video?Object.assign({},e,{video:n.BU(e.video)}):e}function p(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;r<e.iceServers.length;r++){let i=e.iceServers[r];void 0===i.urls&&i.url?(n.io("RTCIceServer.url","RTCIceServer.urls"),i=JSON.parse(JSON.stringify(i)),i.urls=i.url,delete i.url,t.push(i)):t.push(e.iceServers[r])}e.iceServers=t}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function d(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function h(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find(e=>"audio"===e.receiver.track.kind);!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const r=this.getTransceivers().find(e=>"video"===e.receiver.track.kind);!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function u(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}},2634(e,t,r){r.d(t,{BU:()=>m,Gr:()=>o,Rm:()=>p,Rn:()=>a,V1:()=>s,cO:()=>h,co:()=>c,io:()=>d,sc:()=>l});let n=!0,i=!0;function o(e,t,r){const n=e.match(t);return n&&n.length>=r&&parseFloat(n[r],10)}function s(e,t,r){if(!e.RTCPeerConnection)return;if(!Object.getOwnPropertyDescriptor(EventTarget.prototype,"addEventListener").writable)return void p("Unable to polyfill events");const n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);const o=e=>{const t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,o),i.apply(this,[e,o])};const o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);const n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function a(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(n=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function c(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(i=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function p(){if("object"==typeof window){if(n)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function d(e,t){i&&console.warn(e+" is deprecated, please use "+t+" instead.")}function h(e){const t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;const{navigator:r}=e;if(r.userAgentData&&r.userAgentData.brands){const e=r.userAgentData.brands.find(e=>"Chromium"===e.brand);if(e){const t=parseInt(e.version,10);if(t>=90)return{browser:"chrome",version:t}}}if(r.mozGetUserMedia)t.browser="firefox",t.version=parseInt(o(r.userAgent,/Firefox\/(\d+)\./,1));else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=parseInt(o(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2))||null;else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=parseInt(o(r.userAgent,/AppleWebKit\/(\d+)\./,1)),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype,t._safariVersion=o(r.userAgent,/Version\/(\d+(\.?\d+))/,1)}return t}function u(e){return"[object Object]"===Object.prototype.toString.call(e)}function m(e){return u(e)?Object.keys(e).reduce(function(t,r){const n=u(e[r]),i=n?m(e[r]):e[r],o=n&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,{[r]:i})},{}):e}function f(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach(n=>{n.endsWith("Id")?f(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach(t=>{f(e,e.get(t),r)})}))}function l(e,t,r){const n=r?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const o=[];return e.forEach(e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)}),o.forEach(t=>{e.forEach(r=>{r.type===n&&r.trackId===t.id&&f(e,r,i)})}),i}}}]);
|
package/dist/882.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 882.min.js.LICENSE.txt */
|
|
2
|
-
"use strict";(this.webpackChunkMoveoAI=this.webpackChunkMoveoAI||[]).push([[882],{2229:function(t,e,i){i.d(e,{h:function(){return s}});class s{constructor(){this.analyserNode=null,this.audioSource=null,this.animationId=null,this.audioContext=null}start(t,e){try{this.audioContext=new AudioContext,this.audioSource=this.audioContext.createMediaStreamSource(t),this.analyserNode=this.audioContext.createAnalyser(),this.analyserNode.fftSize=256,this.analyserNode.smoothingTimeConstant=.3,this.audioSource.connect(this.analyserNode);const i=new Float32Array(this.analyserNode.fftSize),s=()=>{if(!this.analyserNode)return void this.stop();this.analyserNode.getFloatTimeDomainData(i);let t=0;for(const e of i)t+=e*e;const n=Math.sqrt(t/i.length),o=Math.min(1,10*n);e((o>.01?o:0).toFixed(3)),this.animationId=requestAnimationFrame(s)};s()}catch(t){}}stop(){if(null!==this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.audioSource){try{this.audioSource.disconnect()}catch(t){}this.audioSource=null}this.audioContext&&(this.audioContext.close().catch(()=>{}),this.audioContext=null),this.analyserNode=null}}},6815:function(t,e,i){i.d(e,{n:function(){return s}});const s={NotAllowedError:"Microphone permission denied",NotFoundError:"No microphone found",NotReadableError:"Microphone is in use by another application",OverconstrainedError:"Microphone does not support required settings"}},3564:function(t,e,i){i.d(e,{M:function(){return o}});var s=i(2076);const n={"high-rtt":"High network latency detected","low-mos":"Poor call quality detected","high-jitter":"Network instability detected","high-packet-loss":"Packet loss detected"};class o{constructor(t,e,i,s=5e3){this.pc=t,this.onWarning=e,this.onWarningCleared=i,this.pollIntervalMs=s,this.interval=null,this.prevStats=null,this.activeWarnings=new Set}start(){this.interval=setInterval(()=>{this.pollStats()},this.pollIntervalMs)}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null),this.prevStats=null,this.activeWarnings.clear()}async pollStats(){try{const t=await this.pc.getStats();let e=null,i=0,n=0;const o=(0,s._)(t),r=null!=(null==o?void 0:o.currentRoundTripTime)?1e3*o.currentRoundTripTime:null;t.forEach(t=>{var s,o,r;if("inbound-rtp"===t.type&&"audio"===t.kind){const a=t;e=null!==(s=a.jitter)&&void 0!==s?s:null,i=null!==(o=a.packetsReceived)&&void 0!==o?o:0,n=null!==(r=a.packetsLost)&&void 0!==r?r:0}});let a=0;if(this.prevStats){const t=i-this.prevStats.packetsReceived,e=n-this.prevStats.packetsLost,s=t+e;a=s>0?e/s:0}if(this.prevStats={packetsReceived:i,packetsLost:n},this.checkWarning("high-rtt",null!==r&&r>400),this.checkWarning("high-jitter",null!==e&&e>.03),this.checkWarning("high-packet-loss",a>.03),null!==r&&null!==e){const t=93.2-1e3*e*2-100*a*40-.1*Math.max(0,r-150),i=1+.035*t+t*(t-60)*(100-t)*7e-6;this.checkWarning("low-mos",i<3)}}catch(t){}}checkWarning(t,e){e&&!this.activeWarnings.has(t)?(this.activeWarnings.add(t),this.onWarning(t,n[t]||t)):!e&&this.activeWarnings.has(t)&&(this.activeWarnings.delete(t),this.onWarningCleared(t))}}},6845:function(t,e,i){i.d(e,{PA:function(){return s},TM:function(){return o},Xq:function(){return n}});class s extends Error{constructor(t="Voice service is busy, please try again."){super(t),this.name="ServerBusyError"}}class n extends Error{constructor(t){super(t),this.name="ConfigUnavailableError"}}class o extends Error{constructor(t="Too many attempts. Please try again in a moment."){super(t),this.name="RateLimitedError"}}},7943:function(t,e,i){i.d(e,{$:function(){return r}});var s=i(1931),n=i.n(s),o=i(2076);class r{constructor(t,e,i,s=1e3,o=3,r=!function(t=navigator.userAgent){return/\b(iPad|iPhone|iPod)\b/.test(t)||/AppleWebKit/.test(t)&&!/Chrome|Chromium|CriOS|Edg|OPR/.test(t)}()){this.pc=t,this.onStall=e,this.onRecover=i,this.pollIntervalMs=s,this.flatPollsThreshold=o,this.escalate=r,this.log=n()("moveo:webrtc:media"),this.interval=null,this.prevCounts=null,this.flatPolls=0,this.stalled=!1,this.cannotAssessLogged=!1}start(){this.log("started (escalate=%s)",this.escalate),this.interval=setInterval(()=>{this.poll()},this.pollIntervalMs)}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null),this.prevCounts=null,this.flatPolls=0,this.stalled=!1,this.cannotAssessLogged=!1}async poll(){try{const t=await this.pc.getStats(),e=function(t){const e=new Map;return t.forEach(t=>{if("inbound-rtp"===t.type){const i=t;"audio"===i.kind&&void 0!==i.packetsReceived&&e.set(i.id,i.packetsReceived)}}),e}(t);if(0===e.size)return void(this.cannotAssessLogged||(this.cannotAssessLogged=!0,this.log("cannot assess: no audio inbound-rtp with packetsReceived")));this.cannotAssessLogged=!1;const i=this.prevCounts;if(this.prevCounts=e,null===i)return void this.log("assessing %d audio inbound-rtp report(s)",e.size);let s=!1,n=!1,o=0,r=!1;if(e.forEach((t,e)=>{const a=i.get(e);void 0!==a?(o++,t>a?s=!0:t<a&&(n=!0)):r=!0}),s)return this.stalled&&(this.stalled=!1,this.log("recovered%s (pair %s)",this.escalate?"":" (log-only)",this.describeSelectedPair(t)),this.escalate&&this.onRecover()),void(this.flatPolls=0);if(0===o||n||r)return this.log("inbound-rtp reports reseeded (comparable=%d new=%s)",o,r),void(this.flatPolls=0);this.flatPolls++,this.log("flat poll reports=%d flat=%d",e.size,this.flatPolls),this.flatPolls>=this.flatPollsThreshold&&!this.stalled&&(this.stalled=!0,this.log("stall declared%s after %d flat polls (pair %s)",this.escalate?"":" (log-only, escalation disabled)",this.flatPolls,this.describeSelectedPair(t)),this.escalate&&this.onStall())}catch(t){}}describeSelectedPair(t){const e=(0,o._)(t);return e?(0,o.t)(t,e):"?"}}},2076:function(t,e,i){function s(t){let e;const i=[];t.forEach(t=>{if("transport"===t.type){const{selectedCandidatePairId:i}=t;i&&!e&&(e=i)}else"candidate-pair"===t.type&&i.push(t)});const s=e&&i.find(t=>t.id===e)||i.find(t=>!0===t.selected);if(s)return s;let n;for(const t of i){if(!t.nominated)continue;if(void 0===n){n=t;continue}const e=n.lastPacketReceivedTimestamp,i=t.lastPacketReceivedTimestamp;void 0!==i&&(void 0===e||i>e)&&(n=t)}return n}function n(t,e){const i=e=>{var i,s;if(!e)return"?";const n=t.get(e);if(!n)return"?";const o=`${null!==(i=n.candidateType)&&void 0!==i?i:"?"}/${null!==(s=n.protocol)&&void 0!==s?s:"?"}`;return n.relayProtocol?`${o}(${n.relayProtocol})`:o};return`${i(e.localCandidateId)} -> ${i(e.remoteCandidateId)}`}i.d(e,{_:function(){return s},t:function(){return n}})},4623:function(t,e,i){i.d(e,{g:function(){return r}});var s=i(1931),n=i.n(s),o=i(4587);class r{constructor(t,e,i,s,o){this.url=t,this.sessionToken=e,this.onMessage=i,this.onClose=s,this.onError=o,this.log=n()("moveo:webrtc:media"),this.ws=null}connect(){return new Promise((t,e)=>{this.log("connecting to %s",this.url);const i=`${this.url}?token=${encodeURIComponent(this.sessionToken)}`;this.ws=new WebSocket(i);const s=setTimeout(()=>{this.close(),e(new Error("Signaling connection timed out"))},1e4);this.ws.onopen=()=>{},this.ws.onmessage=e=>{let i;try{i=JSON.parse(e.data)}catch(t){return}this.log("recv %s",i.type),"welcome"===i.type&&(clearTimeout(s),t()),this.onMessage(i)},this.ws.onerror=t=>{clearTimeout(s),this.log("websocket error"),this.onError(t),e(new Error("Signaling WebSocket error"))},this.ws.onclose=t=>{clearTimeout(s),this.log("closed code=%d reason=%s",t.code,t.reason),e(new Error("Signaling WebSocket closed before connection established")),this.onClose(t.code,t.reason)}})}connectForReconnect(t){return new Promise((e,i)=>{this.log("reconnecting to %s",this.url);const s=`${this.url}?token=${encodeURIComponent(this.sessionToken)}`;this.ws=new WebSocket(s);let n=!1;const r=setTimeout(()=>{n||(n=!0,this.close(o.c,"Resume timed out"),i(new Error("Signaling reconnect timed out")))},1e4);this.ws.onopen=()=>{var e;null===(e=this.ws)||void 0===e||e.send(JSON.stringify(t))},this.ws.onmessage=t=>{let s;try{s=JSON.parse(t.data)}catch(t){return}this.log("recv %s",s.type),this.onMessage(s),n||("reconnect_ack"===s.type?(n=!0,clearTimeout(r),e()):"error"===s.type&&(n=!0,clearTimeout(r),i(new Error(`reconnect rejected: ${s.error.code}`))))},this.ws.onerror=t=>{this.log("websocket error"),this.onError(t),n||(n=!0,clearTimeout(r),i(new Error("Signaling WebSocket error")))},this.ws.onclose=t=>{this.log("closed code=%d reason=%s",t.code,t.reason),n||(n=!0,clearTimeout(r),i(new Error("Signaling WebSocket closed before reconnect established"))),this.onClose(t.code,t.reason)}})}send(t){this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.log("send %s",t.type),this.ws.send(JSON.stringify(t)))}close(t=1e3,e="Client closed"){this.ws&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null,this.ws.close(t,e),this.ws=null)}get isConnected(){var t;return(null===(t=this.ws)||void 0===t?void 0:t.readyState)===WebSocket.OPEN}}},5882:function(t,e,i){i.r(e),i.d(e,{WebRTCProvider:function(){return v}}),i(4954);var s=i(1931),n=i.n(s),o=i(4587),r=i(2229),a=i(6815),c=i(3564),l=i(6845),h=i(7943),d=i(4623);const u=500,g=new Set(["session_expired","session_inactive","invalid_credential","max_recovery_exceeded","unexpected_first_frame"]),m={session_expired:"Your session has expired.",session_inactive:"The call has ended.",invalid_credential:"Could not resume the call.",max_recovery_exceeded:"Could not resume the call after several attempts.",unexpected_first_frame:"Could not resume the call."},p=Object.assign(Object.assign({},a.n),{setRemoteDescription:"Connection setup failed",setLocalDescription:"Connection setup failed",addIceCandidate:"Network configuration failed",createOffer:"Browser audio setup failed"});class v{constructor(t,e){this.wsUrl=t,this.fetchConfig=e,this.log=n()("moveo:webrtc:media"),this.pc=null,this.signaling=null,this.localStream=null,this.remoteStream=null,this.remoteAudio=null,this.remoteAudioMonitor=null,this.audioMonitor=null,this.qualityMonitor=null,this.stallDetector=null,this.pendingCandidates=[],this.state="idle",this.eventListeners=new Map,this.iceRestarting=!1,this.iceRestartAttempts=0,this.iceRestartTimeout=null,this.iceRestartAnswerTimeout=null,this.connectResolve=null,this.connectReject=null,this.resuming=!1,this.reconnectAttempts=0,this.reconnectErrorCode=null,this.brainResponseChunks=new Map,this.interruptedRequests=new Map}setConfig(t){this.config=t}async connect(){if(!this.config)throw new Error("Voice config not set; call setConfig() before connect().");this.setState("connecting");try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})}catch(t){const e=t instanceof Error?t.name:"",i=p[e]||"Microphone access failed";throw this.emitError(i),new Error(i)}this.signaling=new d.g(this.wsUrl,this.config.sessionToken,this.handleSignalingMessage.bind(this),this.handleSignalingClose.bind(this),this.handleSignalingError.bind(this));try{await this.signaling.connect()}catch(t){this.cleanupLocalStream();const e=t instanceof Error?t.message:"Signaling connection failed";throw this.emitError(e),new Error(e)}this.pc=new RTCPeerConnection({iceServers:this.config.iceServers,iceTransportPolicy:this.config.iceTransportPolicy||"relay"});const t=this.localStream.getAudioTracks()[0];this.pc.addTrack(t,this.localStream),this.pc.ontrack=this.handleRemoteTrack.bind(this),this.pc.onicecandidate=t=>{var e;t.candidate&&(null===(e=this.signaling)||void 0===e||e.send({type:"ice",candidate:t.candidate.toJSON()}))},this.pc.onconnectionstatechange=this.handleConnectionStateChange.bind(this);try{const t=await this.pc.createOffer();if(!t.sdp)throw new Error("createOffer returned no SDP");await this.pc.setLocalDescription(t),this.signaling.send({type:"offer",sdp:t.sdp})}catch(t){this.cleanup();const e=t instanceof Error?t.name:"createOffer",i=p[e]||"Failed to create call offer";throw this.emitError(i),new Error(i)}return this.audioMonitor=new r.h,this.audioMonitor.start(this.localStream,t=>{this.emit("audio-level",t,Number(t))}),new Promise((t,e)=>{this.connectResolve=t,this.connectReject=e})}disconnect(){this.disconnectInternal(!1)}disconnectInternal(t){var e,i,s,n,o,r,a;if(!t)try{null===(e=this.signaling)||void 0===e||e.send({type:"hangup"})}catch(t){}try{null===(i=this.qualityMonitor)||void 0===i||i.stop(),this.qualityMonitor=null}catch(t){}try{null===(s=this.stallDetector)||void 0===s||s.stop(),this.stallDetector=null}catch(t){}try{null===(n=this.audioMonitor)||void 0===n||n.stop(),this.audioMonitor=null}catch(t){}try{null===(o=this.remoteAudioMonitor)||void 0===o||o.stop(),this.remoteAudioMonitor=null}catch(t){}try{null===(r=this.pc)||void 0===r||r.close(),this.pc=null}catch(t){}this.cleanupLocalStream();try{null===(a=this.signaling)||void 0===a||a.close(),this.signaling=null}catch(t){}try{this.remoteAudio&&(this.remoteAudio.srcObject=null,this.remoteAudio.remove(),this.remoteAudio=null),this.remoteStream=null}catch(t){}this.clearIceRestart(),this.iceRestartAttempts=0,this.connectReject&&this.connectReject(new Error("Call disconnected before connection completed")),this.connectResolve=null,this.connectReject=null,this.resuming=!1,this.reconnectAttempts=0,this.reconnectErrorCode=null,this.originalSessionID=void 0,this.originalConnectionID=void 0,this.pendingCandidates=[],this.brainResponseChunks.clear(),this.interruptedRequests.clear(),this.setState("idle")}toggleMute(){var t,e;const i=null===(t=this.localStream)||void 0===t?void 0:t.getAudioTracks()[0];if(i){i.enabled=!i.enabled;const t=!i.enabled;return null===(e=this.signaling)||void 0===e||e.send({type:"mute",muted:t}),t}return!1}isMuted(){var t,e,i;return!(null===(i=null===(e=null===(t=this.localStream)||void 0===t?void 0:t.getAudioTracks()[0])||void 0===e?void 0:e.enabled)||void 0===i||i)}getLocalStream(){return this.localStream}getRemoteStream(){return this.remoteStream}sendDigits(t){var e;for(const i of t)null===(e=this.signaling)||void 0===e||e.send({type:"dtmf",digit:i})}on(t,e){var i;const s=null!==(i=this.eventListeners.get(t))&&void 0!==i?i:new Set;return s.add(e),this.eventListeners.set(t,s),()=>this.off(t,e)}off(t,e){const i=this.eventListeners.get(t);i&&(i.delete(e),0===i.size&&this.eventListeners.delete(t))}handleRemoteTrack(t){const[e]=t.streams;this.remoteStream=null!=e?e:null,this.remoteAudio=document.createElement("audio"),this.remoteAudio.srcObject=e,this.remoteAudio.autoplay=!0,document.body.appendChild(this.remoteAudio),this.remoteAudio.play().catch(()=>{}),this.remoteAudioMonitor=new r.h,this.remoteAudioMonitor.start(e,t=>{Number(t)>.02&&this.emit("remote-audio",t,Number(t))})}handleConnectionStateChange(){var t,e,i,s;if(this.pc)switch(this.log("connectionState %s",this.pc.connectionState),this.pc.connectionState){case"connecting":this.setState("connecting");break;case"connected":{const s="reconnecting"===this.state;this.setState("connected"),this.clearIceRestart(),this.iceRestartAttempts=0,s&&this.emit("warning-cleared",void 0,"reconnect"),null===(t=this.qualityMonitor)||void 0===t||t.stop(),this.qualityMonitor=new c.M(this.pc,(t,e)=>this.emit("warning",e,t),t=>this.emit("warning-cleared",void 0,t)),this.qualityMonitor.start(),null===(e=this.stallDetector)||void 0===e||e.stop(),this.stallDetector=new h.$(this.pc,()=>{this.log("media stall -> ICE restart"),this.triggerIceRestart()},()=>{this.log("media recovered"),this.clearIceRestart(),this.iceRestartAttempts=0,"reconnecting"===this.state&&this.setState("connected"),this.emit("warning-cleared",void 0,"reconnect")}),this.stallDetector.start(),null===(i=this.connectResolve)||void 0===i||i.call(this),this.connectResolve=null,this.connectReject=null;break}case"disconnected":if(this.resuming)break;this.triggerIceRestart();break;case"failed":if(this.resuming){null===(s=this.connectReject)||void 0===s||s.call(this,new Error("ICE connection failed")),this.connectResolve=null,this.connectReject=null;break}if(this.connectReject){this.connectReject(new Error("ICE connection failed")),this.connectResolve=null,this.connectReject=null,this.emitError("Connection failed"),this.cleanup();break}this.iceRestarting?this.onRestartAttemptExpired():this.triggerIceRestart();break;case"closed":this.cleanup()}}async triggerIceRestart(){if(this.resuming||!this.pc||!this.signaling)return;if(this.iceRestarting||this.iceRestartAttempts>=2)return;if(!this.signaling.isConnected)return this.isResumeEligible()?void this.beginResume(u):(this.emitError("Connection lost"),void this.cleanup());const t=this.pc,e=this.signaling;this.iceRestarting=!0,this.iceRestartAttempts++,this.log("ICE restart attempt %d/%d",this.iceRestartAttempts,2),this.setState("reconnecting"),this.emit("warning","Reconnecting…","reconnect");try{const i=await t.createOffer({iceRestart:!0});if(!i.sdp)throw new Error("createOffer returned no SDP");await t.setLocalDescription(i),e.send({type:"offer",sdp:i.sdp})}catch(e){if(this.resuming||!this.iceRestarting||this.pc!==t)return;return this.iceRestarting=!1,this.emitError("Connection lost"),void this.cleanup()}this.iceRestarting&&this.pc===t&&(this.iceRestartTimeout=setTimeout(()=>{this.onRestartAttemptExpired()},1e4),this.iceRestartAnswerTimeout=setTimeout(()=>{this.onIceRestartUnanswered()},3e3))}onIceRestartUnanswered(){this.iceRestartAnswerTimeout=null,this.iceRestarting&&this.isResumeEligible()&&(this.log("ICE restart offer unanswered -> resume"),this.beginResume(u))}onRestartAttemptExpired(){this.log("ICE restart attempt expired (attempts=%d)",this.iceRestartAttempts),this.iceRestartTimeout&&(clearTimeout(this.iceRestartTimeout),this.iceRestartTimeout=null),this.iceRestartAnswerTimeout&&(clearTimeout(this.iceRestartAnswerTimeout),this.iceRestartAnswerTimeout=null),this.iceRestarting=!1,this.iceRestartAttempts<2?this.triggerIceRestart():this.isResumeEligible()?this.beginResume(u):(this.emitError("Connection lost"),this.cleanup())}clearIceRestart(){this.iceRestarting&&this.log("ICE restart cleared"),this.iceRestartTimeout&&(clearTimeout(this.iceRestartTimeout),this.iceRestartTimeout=null),this.iceRestartAnswerTimeout&&(clearTimeout(this.iceRestartAnswerTimeout),this.iceRestartAnswerTimeout=null),this.iceRestarting=!1}handleSignalingMessage(t){var e;switch(t.type){case"answer":this.handleAnswer(t.sdp);break;case"ice":this.addIceCandidate(t.candidate);break;case"transcript":this.emit("transcript",t.text,{text:t.text,request_id:t.request_id,timestamp:t.timestamp});break;case"brain_response":this.handleBrainResponse(t);break;case"interrupt":this.handleInterrupt(t);break;case"hangup":this.disconnectInternal(!0);break;case"session_ready":this.originalSessionID=t.session_id,this.originalConnectionID=t.connection_id;break;case"reconnect_ack":this.originalConnectionID=t.connection_id;break;case"drain":this.handleDrain(t);break;case"error":this.resuming?(this.reconnectErrorCode=t.error.code,null===(e=this.connectReject)||void 0===e||e.call(this,new Error(`reconnect rejected: ${t.error.code}`))):this.emitError(t.error.message)}}handleSignalingClose(t,e){var i;this.resuming?null===(i=this.connectReject)||void 0===i||i.call(this,new Error("Signaling closed during resume")):this.isResumeEligible()?this.beginResume(u):"idle"!==this.state&&this.disconnect()}handleSignalingError(t){this.resuming||this.isResumeEligible()||"connected"===this.state&&this.emitError("Signaling error")}isResumeEligible(){return!this.resuming&&("connected"===this.state||"reconnecting"===this.state)&&void 0!==this.originalSessionID&&void 0!==this.originalConnectionID}async beginResume(t=0){this.resuming=!0,this.setState("reconnecting"),this.clearIceRestart(),this.emit("warning","Reconnecting…","reconnect"),t>0&&(await this.sleep(Math.random()*t),!this.resuming)||await this.reconnect()}async handleDrain(t){if(!this.resuming)return this.isResumeEligible()?void await this.beginResume(Math.max(0,t.reconnect_delay_ms||0)):(this.emitError("Could not resume the call."),void this.disconnectInternal(!0))}async reconnect(){var t,e,i;try{null===(t=this.pc)||void 0===t||t.getSenders().forEach(t=>{var e;t.track&&(null===(e=this.pc)||void 0===e||e.removeTrack(t))})}catch(t){}const s=null===(e=this.localStream)||void 0===e?void 0:e.getAudioTracks()[0];if(!s||"live"!==s.readyState)return this.emitError("Microphone is no longer available."),void this.disconnectInternal(!0);for(this.teardownForReconnect();this.reconnectAttempts<3;){this.reconnectErrorCode=null;try{if(this.config=await this.fetchConfig(),!this.resuming)return;return this.signaling=new d.g(this.wsUrl,this.config.sessionToken,this.handleSignalingMessage.bind(this),this.handleSignalingClose.bind(this),this.handleSignalingError.bind(this)),await this.signaling.connectForReconnect({type:"reconnect",session_id:this.originalSessionID,connection_id:this.originalConnectionID}),await this.buildReconnectPeerConnection(s),this.reconnectAttempts=0,this.resuming=!1,void this.emit("warning-cleared",void 0,"reconnect")}catch(t){const e=this.reconnectErrorCode;if(e&&g.has(e))return this.emitError(null!==(i=m[e])&&void 0!==i?i:"Could not resume the call."),void this.disconnectInternal(!0);if(t instanceof l.Xq)return this.emitError(t.message),void this.disconnectInternal(!0);const s=t instanceof l.PA?t.message:"Reconnecting…";if(this.emit("warning",s,"reconnect"),this.teardownForReconnect(),this.reconnectAttempts++,this.reconnectAttempts>=3)break;if(await this.sleep(500*this.reconnectAttempts),!this.resuming)return}}this.emitError("Could not resume the call."),this.disconnectInternal(!0)}buildReconnectPeerConnection(t){return this.pc=new RTCPeerConnection({iceServers:this.config.iceServers,iceTransportPolicy:this.config.iceTransportPolicy||"relay"}),this.pc.addTrack(t,this.localStream),this.pc.ontrack=this.handleRemoteTrack.bind(this),this.pc.onicecandidate=t=>{var e;t.candidate&&(null===(e=this.signaling)||void 0===e||e.send({type:"ice",candidate:t.candidate.toJSON()}))},this.pc.onconnectionstatechange=this.handleConnectionStateChange.bind(this),this.audioMonitor=new r.h,this.audioMonitor.start(this.localStream,t=>{this.emit("audio-level",t,Number(t))}),new Promise((t,e)=>{const i=setTimeout(()=>{this.connectResolve=null,this.connectReject=null,e(new Error("Reconnect media resume timed out"))},15e3);this.connectResolve=()=>{clearTimeout(i),t()},this.connectReject=t=>{clearTimeout(i),e(t)},(async()=>{var t;try{const t=await this.pc.createOffer();if(!t.sdp)throw new Error("createOffer returned no SDP");await this.pc.setLocalDescription(t),this.signaling.send({type:"offer",sdp:t.sdp})}catch(e){const i=e instanceof Error?e.name:"createOffer";null===(t=this.connectReject)||void 0===t||t.call(this,new Error(p[i]||"Failed to create call offer"))}})()})}teardownForReconnect(){var t,e,i,s,n,r;try{null===(t=this.qualityMonitor)||void 0===t||t.stop(),this.qualityMonitor=null}catch(t){}try{null===(e=this.stallDetector)||void 0===e||e.stop(),this.stallDetector=null}catch(t){}try{null===(i=this.audioMonitor)||void 0===i||i.stop(),this.audioMonitor=null}catch(t){}try{null===(s=this.remoteAudioMonitor)||void 0===s||s.stop(),this.remoteAudioMonitor=null}catch(t){}try{null===(n=this.pc)||void 0===n||n.close(),this.pc=null}catch(t){}try{null===(r=this.signaling)||void 0===r||r.close(o.c,"Resuming"),this.signaling=null}catch(t){}try{this.remoteAudio&&(this.remoteAudio.srcObject=null,this.remoteAudio.remove(),this.remoteAudio=null),this.remoteStream=null}catch(t){}this.clearIceRestart(),this.iceRestartAttempts=0,this.connectResolve=null,this.connectReject=null,this.pendingCandidates=[]}sleep(t){return new Promise(e=>setTimeout(e,t))}async handleAnswer(t){if(this.iceRestartAnswerTimeout&&(clearTimeout(this.iceRestartAnswerTimeout),this.iceRestartAnswerTimeout=null),this.pc)try{await this.pc.setRemoteDescription({type:"answer",sdp:t}),await this.flushPendingCandidates()}catch(t){this.emitError(p.setRemoteDescription)}}async addIceCandidate(t){var e;if(null===(e=this.pc)||void 0===e?void 0:e.remoteDescription)try{await this.pc.addIceCandidate(t)}catch(t){}else this.pendingCandidates.push(t)}async flushPendingCandidates(){for(const t of this.pendingCandidates){if(!this.pc)break;try{await this.pc.addIceCandidate(t)}catch(t){}}this.pendingCandidates=[]}cleanup(){this.disconnect()}cleanupLocalStream(){var t;try{null===(t=this.localStream)||void 0===t||t.getTracks().forEach(t=>t.stop()),this.localStream=null}catch(t){}}setState(t){this.state=t,this.emit("state-change",t,t)}handleBrainResponse(t){const e=t.request_id;if(this.interruptedRequests.has(e))return;if(t.final){const t=this.assembleBrainResponse(e);return void this.emit("brain-response",t,{text:t,request_id:e,final:!0})}let i=this.brainResponseChunks.get(e);i||(i=new Map,this.brainResponseChunks.set(e,i)),i.set(t.index,t.text);const s=this.assembleBrainResponse(e);this.emit("brain-response",s,{text:s,request_id:e,final:!1})}assembleBrainResponse(t){const e=this.brainResponseChunks.get(t);return e?[...e.entries()].sort((t,e)=>t[0]-e[0]).map(([,t])=>t).join(" "):""}handleInterrupt(t){const e=this.interruptedRequests.get(t.request_id),i=void 0===e?t.heard_index:Math.min(e,t.heard_index);this.interruptedRequests.set(t.request_id,i);const s=this.brainResponseChunks.get(t.request_id),n=s?[...s.entries()].sort((t,e)=>t[0]-e[0]):[],o=t=>n.filter(([e])=>t(e)).map(([,t])=>t).join(" "),r=o(t=>t<=i),a=o(t=>t>i);this.emit("interrupt",r,{request_id:t.request_id,heard_index:i,timestamp:t.timestamp,heardText:r,unheardText:a})}emitError(t){this.emit("error",t),this.setState("error")}emit(t,e,i){const s={state:t,message:e,data:i},n=t=>{const e=this.eventListeners.get(t);e&&e.forEach(t=>{try{t(s)}catch(t){}})};n(t),n("any")}}},4587:function(t,e,i){i.d(e,{c:function(){return s}});const s=4001}}]);
|
|
2
|
+
"use strict";(this.webpackChunkMoveoAI||=[]).push([[882],{2229(t,e,i){i.d(e,{h:()=>s});class s{constructor(){this.analyserNode=null,this.audioSource=null,this.animationId=null,this.audioContext=null}start(t,e){try{this.audioContext=new AudioContext,this.audioSource=this.audioContext.createMediaStreamSource(t),this.analyserNode=this.audioContext.createAnalyser(),this.analyserNode.fftSize=256,this.analyserNode.smoothingTimeConstant=.3,this.audioSource.connect(this.analyserNode);const i=new Float32Array(this.analyserNode.fftSize),s=()=>{if(!this.analyserNode)return void this.stop();this.analyserNode.getFloatTimeDomainData(i);let t=0;for(const e of i)t+=e*e;const n=Math.sqrt(t/i.length),r=Math.min(1,10*n);e((r>.01?r:0).toFixed(3)),this.animationId=requestAnimationFrame(s)};s()}catch{}}stop(){if(null!==this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.audioSource){try{this.audioSource.disconnect()}catch{}this.audioSource=null}this.audioContext&&(this.audioContext.close().catch(()=>{}),this.audioContext=null),this.analyserNode=null}}},6815(t,e,i){i.d(e,["n",0,{NotAllowedError:"Microphone permission denied",NotFoundError:"No microphone found",NotReadableError:"Microphone is in use by another application",OverconstrainedError:"Microphone does not support required settings"}])},3564(t,e,i){i.d(e,{M:()=>r});var s=i(2076);const n={"high-rtt":"High network latency detected","low-mos":"Poor call quality detected","high-jitter":"Network instability detected","high-packet-loss":"Packet loss detected"};class r{constructor(t,e,i,s=5e3){this.pc=t,this.onWarning=e,this.onWarningCleared=i,this.pollIntervalMs=s,this.interval=null,this.prevStats=null,this.activeWarnings=new Set}start(){this.interval=setInterval(()=>{this.pollStats()},this.pollIntervalMs)}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null),this.prevStats=null,this.activeWarnings.clear()}async pollStats(){try{const t=await this.pc.getStats();let e=null,i=0,n=0;const r=(0,s._)(t),o=null!=r?.currentRoundTripTime?1e3*r.currentRoundTripTime:null;t.forEach(t=>{if("inbound-rtp"===t.type&&"audio"===t.kind){const s=t;e=s.jitter??null,i=s.packetsReceived??0,n=s.packetsLost??0}});let a=0;if(this.prevStats){const t=i-this.prevStats.packetsReceived,e=n-this.prevStats.packetsLost,s=t+e;a=s>0?e/s:0}if(this.prevStats={packetsReceived:i,packetsLost:n},this.checkWarning("high-rtt",null!==o&&o>400),this.checkWarning("high-jitter",null!==e&&e>.03),this.checkWarning("high-packet-loss",a>.03),null!==o&&null!==e){const t=93.2-1e3*e*2-100*a*40-.1*Math.max(0,o-150),i=1+.035*t+t*(t-60)*(100-t)*7e-6;this.checkWarning("low-mos",i<3)}}catch{}}checkWarning(t,e){e&&!this.activeWarnings.has(t)?(this.activeWarnings.add(t),this.onWarning(t,n[t]||t)):!e&&this.activeWarnings.has(t)&&(this.activeWarnings.delete(t),this.onWarningCleared(t))}}},6845(t,e,i){i.d(e,{PA:()=>s,TM:()=>r,Xq:()=>n});class s extends Error{constructor(t="Voice service is busy, please try again."){super(t),this.name="ServerBusyError"}}class n extends Error{constructor(t){super(t),this.name="ConfigUnavailableError"}}class r extends Error{constructor(t="Too many attempts. Please try again in a moment."){super(t),this.name="RateLimitedError"}}},7943(t,e,i){i.d(e,{$:()=>o});var s=i(7833),n=i.n(s),r=i(2076);class o{constructor(t,e,i,s=1e3,r=3,o=!function(t=navigator.userAgent){return/\b(iPad|iPhone|iPod)\b/.test(t)||/AppleWebKit/.test(t)&&!/Chrome|Chromium|CriOS|Edg|OPR/.test(t)}()){this.pc=t,this.onStall=e,this.onRecover=i,this.pollIntervalMs=s,this.flatPollsThreshold=r,this.escalate=o,this.log=n()("moveo:webrtc:media"),this.interval=null,this.prevCounts=null,this.flatPolls=0,this.stalled=!1,this.cannotAssessLogged=!1}start(){this.log("started (escalate=%s)",this.escalate),this.interval=setInterval(()=>{this.poll()},this.pollIntervalMs)}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null),this.prevCounts=null,this.flatPolls=0,this.stalled=!1,this.cannotAssessLogged=!1}async poll(){try{const t=await this.pc.getStats(),e=function(t){const e=new Map;return t.forEach(t=>{if("inbound-rtp"===t.type){const i=t;"audio"===i.kind&&void 0!==i.packetsReceived&&e.set(i.id,i.packetsReceived)}}),e}(t);if(0===e.size)return void(this.cannotAssessLogged||(this.cannotAssessLogged=!0,this.log("cannot assess: no audio inbound-rtp with packetsReceived")));this.cannotAssessLogged=!1;const i=this.prevCounts;if(this.prevCounts=e,null===i)return void this.log("assessing %d audio inbound-rtp report(s)",e.size);let s=!1,n=!1,r=0,o=!1;if(e.forEach((t,e)=>{const a=i.get(e);void 0!==a?(r++,t>a?s=!0:t<a&&(n=!0)):o=!0}),s)return this.stalled&&(this.stalled=!1,this.log("recovered%s (pair %s)",this.escalate?"":" (log-only)",this.describeSelectedPair(t)),this.escalate&&this.onRecover()),void(this.flatPolls=0);if(0===r||n||o)return this.log("inbound-rtp reports reseeded (comparable=%d new=%s)",r,o),void(this.flatPolls=0);this.flatPolls++,this.log("flat poll reports=%d flat=%d",e.size,this.flatPolls),this.flatPolls>=this.flatPollsThreshold&&!this.stalled&&(this.stalled=!0,this.log("stall declared%s after %d flat polls (pair %s)",this.escalate?"":" (log-only, escalation disabled)",this.flatPolls,this.describeSelectedPair(t)),this.escalate&&this.onStall())}catch{}}describeSelectedPair(t){const e=(0,r._)(t);return e?(0,r.t)(t,e):"?"}}},2076(t,e,i){function s(t){let e;const i=[];t.forEach(t=>{if("transport"===t.type){const{selectedCandidatePairId:i}=t;i&&!e&&(e=i)}else"candidate-pair"===t.type&&i.push(t)});const s=e&&i.find(t=>t.id===e)||i.find(t=>!0===t.selected);if(s)return s;let n;for(const t of i){if(!t.nominated)continue;if(void 0===n){n=t;continue}const e=n.lastPacketReceivedTimestamp,i=t.lastPacketReceivedTimestamp;void 0!==i&&(void 0===e||i>e)&&(n=t)}return n}function n(t,e){const i=e=>{if(!e)return"?";const i=t.get(e);if(!i)return"?";const s=`${i.candidateType??"?"}/${i.protocol??"?"}`;return i.relayProtocol?`${s}(${i.relayProtocol})`:s};return`${i(e.localCandidateId)} -> ${i(e.remoteCandidateId)}`}i.d(e,{_:()=>s,t:()=>n})},4623(t,e,i){i.d(e,{g:()=>r});var s=i(7833),n=i.n(s);class r{constructor(t,e,i,s,r){this.url=t,this.sessionToken=e,this.onMessage=i,this.onClose=s,this.onError=r,this.log=n()("moveo:webrtc:media"),this.ws=null}connect(){return new Promise((t,e)=>{this.log("connecting to %s",this.url);const i=`${this.url}?token=${encodeURIComponent(this.sessionToken)}`;this.ws=new WebSocket(i);const s=setTimeout(()=>{this.close(),e(new Error("Signaling connection timed out"))},1e4);this.ws.onopen=()=>{},this.ws.onmessage=e=>{let i;try{i=JSON.parse(e.data)}catch{return}this.log("recv %s",i.type),"welcome"===i.type&&(clearTimeout(s),t()),this.onMessage(i)},this.ws.onerror=t=>{clearTimeout(s),this.log("websocket error"),this.onError(t),e(new Error("Signaling WebSocket error"))},this.ws.onclose=t=>{clearTimeout(s),this.log("closed code=%d reason=%s",t.code,t.reason),e(new Error("Signaling WebSocket closed before connection established")),this.onClose(t.code,t.reason)}})}connectForReconnect(t){return new Promise((e,i)=>{this.log("reconnecting to %s",this.url);const s=`${this.url}?token=${encodeURIComponent(this.sessionToken)}`;this.ws=new WebSocket(s);let n=!1;const r=setTimeout(()=>{n||(n=!0,this.close(4001,"Resume timed out"),i(new Error("Signaling reconnect timed out")))},1e4);this.ws.onopen=()=>{this.ws?.send(JSON.stringify(t))},this.ws.onmessage=t=>{let s;try{s=JSON.parse(t.data)}catch{return}this.log("recv %s",s.type),this.onMessage(s),n||("reconnect_ack"===s.type?(n=!0,clearTimeout(r),e()):"error"===s.type&&(n=!0,clearTimeout(r),i(new Error(`reconnect rejected: ${s.error.code}`))))},this.ws.onerror=t=>{this.log("websocket error"),this.onError(t),n||(n=!0,clearTimeout(r),i(new Error("Signaling WebSocket error")))},this.ws.onclose=t=>{this.log("closed code=%d reason=%s",t.code,t.reason),n||(n=!0,clearTimeout(r),i(new Error("Signaling WebSocket closed before reconnect established"))),this.onClose(t.code,t.reason)}})}send(t){this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.log("send %s",t.type),this.ws.send(JSON.stringify(t)))}close(t=1e3,e="Client closed"){this.ws&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.onmessage=null,this.ws.close(t,e),this.ws=null)}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}}},5882(t,e,i){i.r(e),i.d(e,{WebRTCProvider:()=>p}),i(6752);var s=i(7833),n=i.n(s),r=i(2229),o=i(6815),a=i(3564),c=i(6845),h=i(7943),l=i(4623);const d=500,u=new Set(["session_expired","session_inactive","invalid_credential","max_recovery_exceeded","unexpected_first_frame"]),m={session_expired:"Your session has expired.",session_inactive:"The call has ended.",invalid_credential:"Could not resume the call.",max_recovery_exceeded:"Could not resume the call after several attempts.",unexpected_first_frame:"Could not resume the call."},g={...o.n,setRemoteDescription:"Connection setup failed",setLocalDescription:"Connection setup failed",addIceCandidate:"Network configuration failed",createOffer:"Browser audio setup failed"};class p{constructor(t,e){this.wsUrl=t,this.fetchConfig=e,this.log=n()("moveo:webrtc:media"),this.pc=null,this.signaling=null,this.localStream=null,this.remoteStream=null,this.remoteAudio=null,this.remoteAudioMonitor=null,this.audioMonitor=null,this.qualityMonitor=null,this.stallDetector=null,this.pendingCandidates=[],this.state="idle",this.eventListeners=new Map,this.iceRestarting=!1,this.iceRestartAttempts=0,this.iceRestartTimeout=null,this.iceRestartAnswerTimeout=null,this.connectResolve=null,this.connectReject=null,this.resuming=!1,this.reconnectAttempts=0,this.reconnectErrorCode=null,this.brainResponseChunks=new Map,this.interruptedRequests=new Map}setConfig(t){this.config=t}async connect(){if(!this.config)throw new Error("Voice config not set; call setConfig() before connect().");this.setState("connecting");try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})}catch(t){const e=t instanceof Error?t.name:"",i=g[e]||"Microphone access failed";throw this.emitError(i),new Error(i)}this.signaling=new l.g(this.wsUrl,this.config.sessionToken,this.handleSignalingMessage.bind(this),this.handleSignalingClose.bind(this),this.handleSignalingError.bind(this));try{await this.signaling.connect()}catch(t){this.cleanupLocalStream();const e=t instanceof Error?t.message:"Signaling connection failed";throw this.emitError(e),new Error(e)}this.pc=new RTCPeerConnection({iceServers:this.config.iceServers,iceTransportPolicy:this.config.iceTransportPolicy||"relay"});const t=this.localStream.getAudioTracks()[0];this.pc.addTrack(t,this.localStream),this.pc.ontrack=this.handleRemoteTrack.bind(this),this.pc.onicecandidate=t=>{t.candidate&&this.signaling?.send({type:"ice",candidate:t.candidate.toJSON()})},this.pc.onconnectionstatechange=this.handleConnectionStateChange.bind(this);try{const t=await this.pc.createOffer();if(!t.sdp)throw new Error("createOffer returned no SDP");await this.pc.setLocalDescription(t),this.signaling.send({type:"offer",sdp:t.sdp})}catch(t){this.cleanup();const e=t instanceof Error?t.name:"createOffer",i=g[e]||"Failed to create call offer";throw this.emitError(i),new Error(i)}return this.audioMonitor=new r.h,this.audioMonitor.start(this.localStream,t=>{this.emit("audio-level",t,Number(t))}),new Promise((t,e)=>{this.connectResolve=t,this.connectReject=e})}disconnect(){this.disconnectInternal(!1)}disconnectInternal(t){if(!t)try{this.signaling?.send({type:"hangup"})}catch{}try{this.qualityMonitor?.stop(),this.qualityMonitor=null}catch{}try{this.stallDetector?.stop(),this.stallDetector=null}catch{}try{this.audioMonitor?.stop(),this.audioMonitor=null}catch{}try{this.remoteAudioMonitor?.stop(),this.remoteAudioMonitor=null}catch{}try{this.pc?.close(),this.pc=null}catch{}this.cleanupLocalStream();try{this.signaling?.close(),this.signaling=null}catch{}try{this.remoteAudio&&(this.remoteAudio.srcObject=null,this.remoteAudio.remove(),this.remoteAudio=null),this.remoteStream=null}catch{}this.clearIceRestart(),this.iceRestartAttempts=0,this.connectReject&&this.connectReject(new Error("Call disconnected before connection completed")),this.connectResolve=null,this.connectReject=null,this.resuming=!1,this.reconnectAttempts=0,this.reconnectErrorCode=null,this.originalSessionID=void 0,this.originalConnectionID=void 0,this.pendingCandidates=[],this.brainResponseChunks.clear(),this.interruptedRequests.clear(),this.setState("idle")}toggleMute(){const t=this.localStream?.getAudioTracks()[0];if(t){t.enabled=!t.enabled;const e=!t.enabled;return this.signaling?.send({type:"mute",muted:e}),e}return!1}isMuted(){return!(this.localStream?.getAudioTracks()[0]?.enabled??1)}getLocalStream(){return this.localStream}getRemoteStream(){return this.remoteStream}sendDigits(t){for(const e of t)this.signaling?.send({type:"dtmf",digit:e})}on(t,e){const i=this.eventListeners.get(t)??new Set;return i.add(e),this.eventListeners.set(t,i),()=>this.off(t,e)}off(t,e){const i=this.eventListeners.get(t);i&&(i.delete(e),0===i.size&&this.eventListeners.delete(t))}handleRemoteTrack(t){const[e]=t.streams;this.remoteStream=e??null,this.remoteAudio=document.createElement("audio"),this.remoteAudio.srcObject=e,this.remoteAudio.autoplay=!0,document.body.appendChild(this.remoteAudio),this.remoteAudio.play().catch(()=>{}),this.remoteAudioMonitor=new r.h,this.remoteAudioMonitor.start(e,t=>{Number(t)>.02&&this.emit("remote-audio",t,Number(t))})}handleConnectionStateChange(){if(this.pc)switch(this.log("connectionState %s",this.pc.connectionState),this.pc.connectionState){case"connecting":this.setState("connecting");break;case"connected":{const t="reconnecting"===this.state;this.setState("connected"),this.clearIceRestart(),this.iceRestartAttempts=0,t&&this.emit("warning-cleared",void 0,"reconnect"),this.qualityMonitor?.stop(),this.qualityMonitor=new a.M(this.pc,(t,e)=>this.emit("warning",e,t),t=>this.emit("warning-cleared",void 0,t)),this.qualityMonitor.start(),this.stallDetector?.stop(),this.stallDetector=new h.$(this.pc,()=>{this.log("media stall -> ICE restart"),this.triggerIceRestart()},()=>{this.log("media recovered"),this.clearIceRestart(),this.iceRestartAttempts=0,"reconnecting"===this.state&&this.setState("connected"),this.emit("warning-cleared",void 0,"reconnect")}),this.stallDetector.start(),this.connectResolve?.(),this.connectResolve=null,this.connectReject=null;break}case"disconnected":if(this.resuming)break;this.triggerIceRestart();break;case"failed":if(this.resuming){this.connectReject?.(new Error("ICE connection failed")),this.connectResolve=null,this.connectReject=null;break}if(this.connectReject){this.connectReject(new Error("ICE connection failed")),this.connectResolve=null,this.connectReject=null,this.emitError("Connection failed"),this.cleanup();break}this.iceRestarting?this.onRestartAttemptExpired():this.triggerIceRestart();break;case"closed":this.cleanup()}}async triggerIceRestart(){if(this.resuming||!this.pc||!this.signaling)return;if(this.iceRestarting||this.iceRestartAttempts>=2)return;if(!this.signaling.isConnected)return this.isResumeEligible()?void this.beginResume(d):(this.emitError("Connection lost"),void this.cleanup());const t=this.pc,e=this.signaling;this.iceRestarting=!0,this.iceRestartAttempts++,this.log("ICE restart attempt %d/%d",this.iceRestartAttempts,2),this.setState("reconnecting"),this.emit("warning","Reconnecting…","reconnect");try{const i=await t.createOffer({iceRestart:!0});if(!i.sdp)throw new Error("createOffer returned no SDP");await t.setLocalDescription(i),e.send({type:"offer",sdp:i.sdp})}catch{if(this.resuming||!this.iceRestarting||this.pc!==t)return;return this.iceRestarting=!1,this.emitError("Connection lost"),void this.cleanup()}this.iceRestarting&&this.pc===t&&(this.iceRestartTimeout=setTimeout(()=>{this.onRestartAttemptExpired()},1e4),this.iceRestartAnswerTimeout=setTimeout(()=>{this.onIceRestartUnanswered()},3e3))}onIceRestartUnanswered(){this.iceRestartAnswerTimeout=null,this.iceRestarting&&this.isResumeEligible()&&(this.log("ICE restart offer unanswered -> resume"),this.beginResume(d))}onRestartAttemptExpired(){this.log("ICE restart attempt expired (attempts=%d)",this.iceRestartAttempts),this.iceRestartTimeout&&(clearTimeout(this.iceRestartTimeout),this.iceRestartTimeout=null),this.iceRestartAnswerTimeout&&(clearTimeout(this.iceRestartAnswerTimeout),this.iceRestartAnswerTimeout=null),this.iceRestarting=!1,this.iceRestartAttempts<2?this.triggerIceRestart():this.isResumeEligible()?this.beginResume(d):(this.emitError("Connection lost"),this.cleanup())}clearIceRestart(){this.iceRestarting&&this.log("ICE restart cleared"),this.iceRestartTimeout&&(clearTimeout(this.iceRestartTimeout),this.iceRestartTimeout=null),this.iceRestartAnswerTimeout&&(clearTimeout(this.iceRestartAnswerTimeout),this.iceRestartAnswerTimeout=null),this.iceRestarting=!1}handleSignalingMessage(t){switch(t.type){case"answer":this.handleAnswer(t.sdp);break;case"ice":this.addIceCandidate(t.candidate);break;case"transcript":this.emit("transcript",t.text,{text:t.text,request_id:t.request_id,timestamp:t.timestamp});break;case"brain_response":this.handleBrainResponse(t);break;case"interrupt":this.handleInterrupt(t);break;case"hangup":this.disconnectInternal(!0);break;case"session_ready":this.originalSessionID=t.session_id,this.originalConnectionID=t.connection_id;break;case"reconnect_ack":this.originalConnectionID=t.connection_id;break;case"drain":this.handleDrain(t);break;case"error":this.resuming?(this.reconnectErrorCode=t.error.code,this.connectReject?.(new Error(`reconnect rejected: ${t.error.code}`))):this.emitError(t.error.message)}}handleSignalingClose(t,e){this.resuming?this.connectReject?.(new Error("Signaling closed during resume")):this.isResumeEligible()?this.beginResume(d):"idle"!==this.state&&this.disconnect()}handleSignalingError(t){this.resuming||this.isResumeEligible()||"connected"===this.state&&this.emitError("Signaling error")}isResumeEligible(){return!this.resuming&&("connected"===this.state||"reconnecting"===this.state)&&void 0!==this.originalSessionID&&void 0!==this.originalConnectionID}async beginResume(t=0){this.resuming=!0,this.setState("reconnecting"),this.clearIceRestart(),this.emit("warning","Reconnecting…","reconnect"),t>0&&(await this.sleep(Math.random()*t),!this.resuming)||await this.reconnect()}async handleDrain(t){if(!this.resuming)return this.isResumeEligible()?void await this.beginResume(Math.max(0,t.reconnect_delay_ms||0)):(this.emitError("Could not resume the call."),void this.disconnectInternal(!0))}async reconnect(){try{this.pc?.getSenders().forEach(t=>{t.track&&this.pc?.removeTrack(t)})}catch{}const t=this.localStream?.getAudioTracks()[0];if(!t||"live"!==t.readyState)return this.emitError("Microphone is no longer available."),void this.disconnectInternal(!0);for(this.teardownForReconnect();this.reconnectAttempts<3;){this.reconnectErrorCode=null;try{if(this.config=await this.fetchConfig(),!this.resuming)return;return this.signaling=new l.g(this.wsUrl,this.config.sessionToken,this.handleSignalingMessage.bind(this),this.handleSignalingClose.bind(this),this.handleSignalingError.bind(this)),await this.signaling.connectForReconnect({type:"reconnect",session_id:this.originalSessionID,connection_id:this.originalConnectionID}),await this.buildReconnectPeerConnection(t),this.reconnectAttempts=0,this.resuming=!1,void this.emit("warning-cleared",void 0,"reconnect")}catch(t){const e=this.reconnectErrorCode;if(e&&u.has(e))return this.emitError(m[e]??"Could not resume the call."),void this.disconnectInternal(!0);if(t instanceof c.Xq)return this.emitError(t.message),void this.disconnectInternal(!0);const i=t instanceof c.PA?t.message:"Reconnecting…";if(this.emit("warning",i,"reconnect"),this.teardownForReconnect(),this.reconnectAttempts++,this.reconnectAttempts>=3)break;if(await this.sleep(500*this.reconnectAttempts),!this.resuming)return}}this.emitError("Could not resume the call."),this.disconnectInternal(!0)}buildReconnectPeerConnection(t){return this.pc=new RTCPeerConnection({iceServers:this.config.iceServers,iceTransportPolicy:this.config.iceTransportPolicy||"relay"}),this.pc.addTrack(t,this.localStream),this.pc.ontrack=this.handleRemoteTrack.bind(this),this.pc.onicecandidate=t=>{t.candidate&&this.signaling?.send({type:"ice",candidate:t.candidate.toJSON()})},this.pc.onconnectionstatechange=this.handleConnectionStateChange.bind(this),this.audioMonitor=new r.h,this.audioMonitor.start(this.localStream,t=>{this.emit("audio-level",t,Number(t))}),new Promise((t,e)=>{const i=setTimeout(()=>{this.connectResolve=null,this.connectReject=null,e(new Error("Reconnect media resume timed out"))},15e3);this.connectResolve=()=>{clearTimeout(i),t()},this.connectReject=t=>{clearTimeout(i),e(t)},(async()=>{try{const t=await this.pc.createOffer();if(!t.sdp)throw new Error("createOffer returned no SDP");await this.pc.setLocalDescription(t),this.signaling.send({type:"offer",sdp:t.sdp})}catch(t){const e=t instanceof Error?t.name:"createOffer";this.connectReject?.(new Error(g[e]||"Failed to create call offer"))}})()})}teardownForReconnect(){try{this.qualityMonitor?.stop(),this.qualityMonitor=null}catch{}try{this.stallDetector?.stop(),this.stallDetector=null}catch{}try{this.audioMonitor?.stop(),this.audioMonitor=null}catch{}try{this.remoteAudioMonitor?.stop(),this.remoteAudioMonitor=null}catch{}try{this.pc?.close(),this.pc=null}catch{}try{this.signaling?.close(4001,"Resuming"),this.signaling=null}catch{}try{this.remoteAudio&&(this.remoteAudio.srcObject=null,this.remoteAudio.remove(),this.remoteAudio=null),this.remoteStream=null}catch{}this.clearIceRestart(),this.iceRestartAttempts=0,this.connectResolve=null,this.connectReject=null,this.pendingCandidates=[]}sleep(t){return new Promise(e=>setTimeout(e,t))}async handleAnswer(t){if(this.iceRestartAnswerTimeout&&(clearTimeout(this.iceRestartAnswerTimeout),this.iceRestartAnswerTimeout=null),this.pc)try{await this.pc.setRemoteDescription({type:"answer",sdp:t}),await this.flushPendingCandidates()}catch{this.emitError(g.setRemoteDescription)}}async addIceCandidate(t){if(this.pc?.remoteDescription)try{await this.pc.addIceCandidate(t)}catch{}else this.pendingCandidates.push(t)}async flushPendingCandidates(){for(const t of this.pendingCandidates){if(!this.pc)break;try{await this.pc.addIceCandidate(t)}catch{}}this.pendingCandidates=[]}cleanup(){this.disconnect()}cleanupLocalStream(){try{this.localStream?.getTracks().forEach(t=>t.stop()),this.localStream=null}catch{}}setState(t){this.state=t,this.emit("state-change",t,t)}handleBrainResponse(t){const e=t.request_id;if(this.interruptedRequests.has(e))return;if(t.final){const t=this.assembleBrainResponse(e);return void this.emit("brain-response",t,{text:t,request_id:e,final:!0})}let i=this.brainResponseChunks.get(e);i||(i=new Map,this.brainResponseChunks.set(e,i)),i.set(t.index,t.text);const s=this.assembleBrainResponse(e);this.emit("brain-response",s,{text:s,request_id:e,final:!1})}assembleBrainResponse(t){const e=this.brainResponseChunks.get(t);return e?[...e.entries()].sort((t,e)=>t[0]-e[0]).map(([,t])=>t).join(" "):""}handleInterrupt(t){const e=this.interruptedRequests.get(t.request_id),i=void 0===e?t.heard_index:Math.min(e,t.heard_index);this.interruptedRequests.set(t.request_id,i);const s=this.brainResponseChunks.get(t.request_id),n=s?[...s.entries()].sort((t,e)=>t[0]-e[0]):[],r=t=>n.filter(([e])=>t(e)).map(([,t])=>t).join(" "),o=r(t=>t<=i),a=r(t=>t>i);this.emit("interrupt",o,{request_id:t.request_id,heard_index:i,timestamp:t.timestamp,heardText:o,unheardText:a})}emitError(t){this.emit("error",t),this.setState("error")}emit(t,e,i){const s={state:t,message:e,data:i},n=t=>{const e=this.eventListeners.get(t);e&&e.forEach(t=>{try{t(s)}catch{}})};n(t),n("any")}}}}]);
|
package/dist/929.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 929.min.js.LICENSE.txt */
|
|
2
|
-
"use strict";(this.webpackChunkMoveoAI
|
|
2
|
+
"use strict";(this.webpackChunkMoveoAI||=[]).push([[929],{7929(e,t,r){r.r(t);var o=r(6845);const n=async(e,t)=>{const r=new AbortController,n=setTimeout(()=>r.abort(),1e4);let s;try{s=await fetch(((e,t)=>`${e}/v1/webvoice/${encodeURIComponent(t)}/config`)(e,t),{method:"GET",signal:r.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw new Error("Config request timed out.");throw e}finally{clearTimeout(n)}if(!s.ok){if(404===s.status)throw new Error(`Integration ID "${t}" was not found.`);if(403===s.status)throw new o.Xq("Voice calling is currently unavailable.");if(429===s.status)throw new o.TM;if(503===s.status){let e;try{e=(await s.json()).error_code}catch{}if("turn_unavailable"===e||"signing_unavailable"===e)throw new o.Xq("Voice calling is unavailable on this deployment.");if("server_busy"===e)throw new o.PA}throw new Error(`Unable to fetch config (status ${s.status} ${s.statusText}).`)}const i=await s.json();if(!i.iceServers||!i.sessionToken)throw new Error("Invalid config response: missing iceServers or sessionToken");return i};r.d(t,["buildWebVoiceWsUrl",0,(e,t)=>e.replace(/^https:/,"wss:").replace(/^http:/,"ws:")+`/v1/webvoice/${encodeURIComponent(t)}/rtc`,"fetchWebVoiceConfig",0,async(e,t)=>{let r=0;for(;;)try{return await n(e,t)}catch(e){if(e instanceof o.PA&&r<2){r++,await new Promise(e=>setTimeout(e,500*r));continue}throw e}}])},6845(e,t,r){r.d(t,{PA:()=>o,TM:()=>s,Xq:()=>n});class o extends Error{constructor(e="Voice service is busy, please try again."){super(e),this.name="ServerBusyError"}}class n extends Error{constructor(e){super(e),this.name="ConfigUnavailableError"}}class s extends Error{constructor(e="Too many attempts. Please try again in a moment."){super(e),this.name="RateLimitedError"}}}}]);
|