2 lines
63 KiB
JavaScript
2 lines
63 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[9954],{99447:(e,t,a)=>{a.r(t),a.d(t,{ActiveCallHeader:()=>tt,GroupCall:()=>et,PhoneCall:()=>st,RatePhoneCallModal:()=>ct});var n=a(88422),i=a(97184),o=a(83716);function s(e){return e<<0}function r(e){return e>>>0}function c(e,t=3){if(!e)return 0;const{length:a}=e;let n=0;for(let t=0;t<a;t++)n+=e[t]*e[t];const i=Math.sqrt(n/a)/255;return Math.min(1,i*t)}function l(e){return{id:e.id,name:e.name,"rtcp-fbs":e.feedbackTypes,clockrate:e.clockrate,parameters:e.parameters,channels:e.channels}}const d=.1,u="getDisplayMedia"in(navigator?.mediaDevices||{}),p=navigator?.mediaDevices?.getSupportedConstraints().echoCancellation,m=navigator?.mediaDevices?.getSupportedConstraints().noiseSuppression,g=(e,t=!1)=>{if(!e||!e.sdp)throw Error("Failed parsing SDP: session description is null");const a=e.sdp.split("\r\nm=").map(((e,t)=>0===t?e:`m=${e}`)).reduce(((e,t)=>{const a=t.match(/^m=(.+?)\s/)?.[1]||"header";return e[e.hasOwnProperty(a)&&"video"===a?"screencast":a]=t.split("\r\n").filter(Boolean),e}),{}),n=(e,t)=>t?a[t]?.find((t=>t.startsWith(e)))?.substr(e.length):Object.values(a).map((t=>t.find((t=>t.startsWith(e)))?.substr(e.length))).filter(Boolean)[0],i=e=>a[e].filter((e=>e.startsWith("a=extmap"))).map((e=>{const[,t,a]=e.match(/extmap:(\d+)(?:\/.+)?\s(.+)/);return{id:Number(t),uri:a}})),o=e=>{const t=a[e].filter((e=>e.startsWith("a=rtpmap"))).map((e=>{const[,t,a]=e.match(/:(\d+)\s(.+)/)||[],[n,i,o]=a.split("/");return{id:Number(t),name:n,clockrate:Number(i),...o&&{channels:Number(o)}}})),n=a[e].filter((e=>e.startsWith("a=rtcp-fb"))).map((e=>{const[,t,a]=e.match(/:(\d+)\s(.+)/)||[],[n,i]=a.split(" ");return{id:Number(t),type:n,subtype:i||""}})),i=a[e].filter((e=>e.startsWith("a=fmtp"))).map((e=>{const[,t,a]=e.match(/:(\d+)\s(.+)/)||[],n=a.split(";").reduce(((e,t)=>{const[a,n]=t.split("=");return e[a]=n,e}),{});if(!Object.values(n).some((e=>!e)))return{id:Number(t),data:n}})).filter(Boolean);return t.map((e=>{const t=i.filter((t=>t.id===e.id)).map((e=>e.data)).reduce(((e,t)=>Object.assign(e,t)),{}),a=n.filter((t=>t.id===e.id)).map((e=>({type:e.type,subtype:e.subtype})));return{...e,...Object.keys(t).length>0&&{parameters:t},...a.length>0&&{feedbackTypes:a}}}))},r=n("a=ssrc:","audio"),c=r&&Number(r.split(" ")[0]),l=n("a=ssrc-group:","video")?.split(" ")||void 0,d=n("a=ssrc-group:","screencast")?.split(" ")||void 0;if(!l)throw Error("Failed parsing SDP: no video ssrc");const[u,p]=n("a=fingerprint:")?.split(" ")||[],m=n("a=setup:");if(!u||!p)throw Error("Failed parsing SDP: no fingerprint");console.log(a);const g=n("a=ice-ufrag:"),f=n("a=ice-pwd:");if(!g||!f)throw Error("Failed parsing SDP: no ICE ufrag or pwd");return{fingerprints:[{fingerprint:p,hash:u,setup:t?m:"active"}],pwd:f,ufrag:g,...c&&{ssrc:s(c)},...l&&{"ssrc-groups":[{semantics:l[0],sources:l.slice(1,l.length).map(Number).map(s)},t&&d&&{semantics:d[0],sources:d.slice(1,d.length).map(Number).map(s)}].filter(Boolean)},...t&&{audioExtmap:i("audio"),videoExtmap:i("video"),screencastExtmap:i("screencast"),audioPayloadTypes:o("audio"),videoPayloadTypes:o("video"),screencastPayloadTypes:o("screencast")}}},f=(e,t=!1,a=!1,n=!1)=>{const i=[],o=e=>{i.push(e)},{sessionId:s,ssrcs:c,audioExtensions:l,videoExtensions:d,audioPayloadTypes:u,videoPayloadTypes:p,transport:{ufrag:m,pwd:g,fingerprints:f,candidates:v}}=e;o("v=0"),o(`o=- ${s} 2 IN IP4 0.0.0.0`),o("s=-"),o("t=0 0"),o("a=ice-options:trickle"),o("a=msid-semantic:WMS *"),o(`a=group:BUNDLE ${c.map((e=>e.mid)).join(" ")}${a?"":" "+(n?"3":"2")}`),n||o("a=ice-lite");const h=e=>{if(e.sdpString)o(`a=${e.sdpString}`);else{let t="";t+="a=candidate:",t+=`${e.foundation} ${e.component} ${e.protocol} ${e.priority} ${e.ip} ${e.port} typ ${e.type}`,"rel-addr"in e&&(t+=` raddr ${e["rel-addr"]} rport ${e["rel-port"]}`),t+=` generation ${e.generation}`,o(t)}},C=()=>{o(`a=ice-ufrag:${m}`),o(`a=ice-pwd:${g}`),f.forEach((e=>{o(`a=fingerprint:${e.hash} ${e.fingerprint}`),o(`a=setup:${n?e.setup:"passive"}`)})),v.forEach(h)},Z=e=>{const{channels:t,id:a,name:n,clockrate:i,parameters:s}=e;if(o(`a=rtpmap:${a} ${n}/${i}${t?`/${t}`:""}`),s){const e=Object.keys(s).map((e=>`${e}=${s[e]};`)).join(" ");o(`a=fmtp:${a} ${e}`)}e["rtcp-fbs"]?.forEach((e=>{o(`a=rtcp-fb:${a} ${e.type}${e.subtype?` ${e.subtype}`:""}`)}))},P=e=>{const a=e.isVideo?p:u,i=e.isVideo?"video":"audio";if(o(`m=${i} ${e.isMain?1:0} RTP/SAVPF ${a.map((e=>e.id)).join(" ")}`),o("c=IN IP4 0.0.0.0"),o("b=AS:1300"),o(`a=mid:${e.mid}`),o("a=rtcp-mux"),a.forEach(Z),o("a=rtcp:1 IN IP4 0.0.0.0"),e.isVideo&&o("a=rtcp-rsize"),(e.isVideo?d:l).forEach((({id:e,uri:t})=>{o(`a=extmap:${e} ${t}`)})),e.isRemoved)o("a=inactive");else{if(C(),n)o("a=sendrecv"),o("a=bundle-only");else{if(t)return void o("a=recvonly");e.isMain?o("a=sendrecv"):(o("a=sendonly"),o("a=bundle-only"))}e.sourceGroups.forEach((t=>{t.semantics&&o(`a=ssrc-group:${t.semantics} ${t.sources.map(r).join(" ")}`),t.sources.forEach((t=>{const a=r(t);o(`a=ssrc:${a} cname:${e.endpoint}`),o(`a=ssrc:${a} msid:${e.endpoint} ${e.endpoint}`),o(`a=ssrc:${a} mslabel:${e.endpoint}`),o(`a=ssrc:${a} label:${e.endpoint}`)}))}))}};return n?c.filter(P):c.filter((e=>"0"===e.mid||"1"===e.mid)).map(P),a||(o("m=application 1 UDP/DTLS/SCTP webrtc-datachannel"),o("c=IN IP4 0.0.0.0"),C(),o("a=ice-options:trickle"),o("a=mid:"+(n?"3":a?"1":"2")),o("a=sctp-port:5000"),o("a=max-message-size:262144")),n||c.filter((e=>"0"!==e.mid&&"1"!==e.mid)).map(P),`${i.join("\n")}\n`},v=e=>{const t=e.createOscillator(),a=t.connect(e.createMediaStreamDestination());return t.start(),new MediaStream([Object.assign(a.stream.getAudioTracks()[0],{enabled:!1})])},h=({width:e=640,height:t=480}={})=>{const a=Object.assign(document.createElement("canvas"),{width:e,height:t}),n=a.getContext("2d");if(!n)throw Error("Cannot create canvas ctx");n.fillRect(0,0,e,t);const i=a.captureStream();return new MediaStream([Object.assign(i.getVideoTracks()[0],{enabled:!1})])};var C=a(46586),Z=a(74753);let P,y;function b(e){P&&(P.screenshareDataChannel?.close(),P.screenshareConnection?.close(),e||P.onUpdate?.({"@type":"updateGroupCallLeavePresentation"}))}function w(e){return P?.streams?.[e]}function E(e,t){const a=P?.participantFunctions?.[e];a&&a.setVolume?.(t)}function S(e,t){const a=t||P?.myId,n=a&&w(a)?.[e];return!!n&&n.getTracks()[0]?.enabled}function k(e){P?.onUpdate?.({"@type":"updateGroupCallStreams",userId:e,hasAudioStream:S("audio",e),hasVideoStream:S("video",e),hasPresentationStream:S("presentation",e),amplitude:P.speaking?.[e]})}async function I(e,t="user"){if("audio"===e&&P?.audioStream)return P.audioStream;if("presentation"===e)return navigator.mediaDevices.getDisplayMedia({audio:!1,video:!0});const a=await navigator.mediaDevices.getUserMedia({audio:"audio"===e&&{...p&&{echoCancellation:!0},...m&&{noiseSuppression:!0}},video:"video"===e&&{facingMode:t}});if(P&&"audio"===e&&(P.audioStream=a),"video"===e){const e=document.createElement("video");e.srcObject=a;const t=new C.Z;e.oncanplay=()=>t.resolve(),await t.promise}return a}async function N(e,t=void 0){if(!(P&&P.myId&&P.connection&&P.streams))return;const a=w(P.myId)?.[e];if(!a)return;const n=a.getTracks()[0];if(!n)return;const i=[...P.connection.getSenders(),...P.screenshareConnection?.getSenders()||[]].find((e=>n.id===e.track?.id));if(i){t=void 0===t?!n.enabled:t;try{if(t&&!n.enabled){const t=await I(e);if(await i.replaceTrack(t.getTracks()[0]),P.streams[P.myId][e]=t,"video"===e)P.facingMode="user";else if("audio"===e){const{audioContext:e}=P;if(!e)return;const a=P.audioSource||e.createMediaStreamSource(t),n=P.audioAnalyser||e.createAnalyser();n.minDecibels=-100,n.maxDecibels=-30,n.smoothingTimeConstant=.05,n.fftSize=1024,a.connect(n),P={...P,audioSource:a,audioAnalyser:n,participantFunctions:{...P.participantFunctions,[P.myId]:{...P.participantFunctions?.[P.myId],getCurrentAmplitude:()=>{const e=new Uint8Array(n.frequencyBinCount);return n.getByteFrequencyData(e),c(e,1.5)}}}}}}else if(!t&&n.enabled){const t="audio"===e?P.silence:P.black;if(!t)return;await i.replaceTrack(t.getTracks()[0]),P.streams[P.myId][e]=t,"video"===e&&(P.facingMode=void 0),"audio"!==e?n.stop():(P.audioSource?.disconnect(),P.audioAnalyser?.disconnect())}k(P.myId),"presentation"!==e||t||b(!0)}catch(e){}}}function T(e){P?.onUpdate?.({"@type":"updateGroupCallConnectionState",connectionState:e})}function M(){P&&(P.myId&&P.streams?.[P.myId]&&Object.values(P.streams[P.myId]||{}).forEach((e=>{e?.getTracks().forEach((e=>{e.stop()}))})),P.audioStream?.getTracks().forEach((e=>{e.stop()})),b(!0),P.dataChannel?.close(),P.connection?.close(),T("disconnected"),P.analyserInterval&&clearInterval(P.analyserInterval),P=void 0)}function V(){P&&P.participantFunctions&&Object.keys(P.participantFunctions).forEach((e=>{const{getCurrentAmplitude:t}=P.participantFunctions[Number(e)];if(t){const a=t(),n=P.speaking[e]||0;P.speaking[e]=a,(a>d&&n<=d||a<=d&&n>d)&&k(e)}}))}async function R(e){if(!P)return;const{participants:t,conference:a,connection:n,myId:i}=P;if(!(t&&a&&n&&a.ssrcs&&a.transport&&i))return;if(e.find((e=>e.isSelf&&e.source!==P?.conference?.ssrcs?.find((e=>e.isMain&&!e.isVideo))?.sourceGroups[0].sources[0])))return void M();const o=[];if(e.forEach((e=>{if(e.isSelf)return void(e.isMuted&&!e.canSelfUnmute&&(N("audio",!1),N("video",!1),N("presentation",!1)));const{isLeft:t}=e,n=e.isMuted||e.isMutedByMe,i=!e.isVideoJoined||!e.video||t,s=!e.presentation||t;let r=!1,c=!1,l=!1;a.ssrcs.filter((t=>t.userId===e.id)).forEach((t=>{t.isVideo||(t.sourceGroups[0].sources[0]===e.source&&(c=!0),t.isRemoved=n),t.isVideo&&(t.isPresentation||(e.video&&t.endpoint===e.video.endpoint&&(r=!0),t.isRemoved=i),t.isPresentation&&(e.presentation&&t.endpoint===e.presentation.endpoint&&(l=!0),t.isRemoved=s))})),n||c||(P.lastMid=P.lastMid+1,a.ssrcs.push({userId:e.id,isMain:!1,endpoint:`audio${e.source}`,isVideo:!1,sourceGroups:[{sources:[e.source]}],mid:P.lastMid.toString()})),i||r||!e.video||(P.lastMid=P.lastMid+1,o.push(e.video.endpoint),a.ssrcs.push({userId:e.id,isMain:!1,endpoint:e.video.endpoint,isVideo:!0,sourceGroups:e.video.sourceGroups,mid:P.lastMid.toString()})),s||l||!e.presentation||(P.lastMid=P.lastMid+1,a.ssrcs.push({isPresentation:!0,userId:e.id,isMain:!1,endpoint:e.presentation.endpoint,isVideo:!0,sourceGroups:e.presentation.sourceGroups,mid:P.lastMid.toString()}))})),P.updatingParticipantsQueue)return void P.updatingParticipantsQueue.push(a);P.updatingParticipantsQueue=[];const s=f(a);await n.setRemoteDescription({type:"offer",sdp:s});try{const e=await n.createAnswer();if(await n.setLocalDescription(e),k(i),P.updatingParticipantsQueue.length>0)for(const e of P.updatingParticipantsQueue){await n.setRemoteDescription({type:"offer",sdp:f(e)});const t=await n.createAnswer();await n.setLocalDescription(t),k(i)}P.updatingParticipantsQueue=void 0}catch(e){console.error(e)}}function G(e){if(!(P&&P.audioElement&&P.audioContext&&P.mediaStream))return;const t=P.conference?.ssrcs?.find((t=>t.endpoint===e.track.id));if(!t||!t.userId)return;const{userId:a,isPresentation:n}=t,i=P.participants?.find((e=>e.id===a)),o="video"===e.track.kind?n?"presentation":"video":"audio";e.track.onended=()=>{delete P?.streams?.[a][o],k(a)};const s=e.streams[0];if("audio"===e.track.kind){const{mediaStream:e}=P,t=new window.AudioContext,n=t.createMediaStreamSource(s),o=t.createGain();o.gain.value=(i?.volume||1e4)/1e4;const r=t.createGain();o.gain.value=1;const l=t.createAnalyser();l.minDecibels=-100,l.maxDecibels=-30,l.smoothingTimeConstant=.05,l.fftSize=1024,n.connect(l).connect(r).connect(o).connect(t.destination),e.addTrack(n.mediaStream.getAudioTracks()[0]);const d=new Audio;d.srcObject=s,d.muted=!0,d.remove(),P={...P,participantFunctions:{...P.participantFunctions,[a]:{...P.participantFunctions?.[a],setVolume:e=>{o.gain.value=e>1?2*e:e},toggleMute:e=>{r.gain.value=e?0:1},getCurrentAmplitude:()=>{const e=new Uint8Array(l.frequencyBinCount);return l.getByteFrequencyData(e),c(e,1.5)}}}}}P={...P,streams:{...P.streams,[a]:{...P.streams?.[a],[o]:s}}},k(a)}function O(e,t,a=!1){const n=new RTCPeerConnection,i=a?void 0:function(e){const t=e.createDataChannel("data",{id:0});return t.onopen=()=>{},t.onmessage=e=>{JSON.parse(e.data).colibriClass},t.onerror=e=>{console.log("%conerror","background: green; font-size: 5em"),console.error(e)},t}(n);return e.forEach((e=>e.getTracks().forEach((t=>{n.addTrack(t,e)})))),a||(n.oniceconnectionstatechange=()=>{const e=n.iceConnectionState;console.log("iceconnectionstatechange",e),"connected"===e||"completed"===e?T("connected"):"checking"===e||"new"===e?T("connecting"):"disconnected"===n.iceConnectionState&&T("reconnecting")}),n.onconnectionstatechange=()=>{console.log("connectionstatechange",n.connectionState)},n.ontrack=G,n.onnegotiationneeded=async()=>{if(!P)return;console.log("onnegotiationneeded");const{myId:i}=P;if(!i)return;const o=await n.createOffer({offerToReceiveVideo:!0,offerToReceiveAudio:!a});if(console.log("offer created"),await n.setLocalDescription(o),console.log("local desc set"),!o.sdp)return;const s=g(o),r=a?void 0:{userId:"",sourceGroups:[{sources:[s.ssrc||0]}],isRemoved:a,isMain:!0,isVideo:!1,isPresentation:a,endpoint:a?"1":"0",mid:a?"1":"0"},c=s["ssrc-groups"]&&{isPresentation:a,userId:"",sourceGroups:s["ssrc-groups"],isMain:!0,isVideo:!0,endpoint:a?"0":"1",mid:a?"0":"1"},l=a?P.screenshareConference:P.conference,d=[];a?(c&&d.push(c),r&&d.push(r)):(r&&d.push(r),c&&d.push(c));const u=e.find((e=>"audio"===e.getTracks()[0].kind)),p=e.find((e=>"video"===e.getTracks()[0].kind));P={...P,...a?{screenshareConference:{...l,ssrcs:d}}:{conference:{...l,ssrcs:d}},streams:{...P.streams,[i]:{...P.streams?.[i],...u&&{audio:u},...!a&&p?{video:p}:{presentation:p}}}},k(i),t(s)},{connection:n,dataChannel:i}}function x(){y?.onUpdate({...y.mediaState,"@type":"updatePhoneCallMediaState"})}function B(e,t="user"){return"presentation"===e?navigator.mediaDevices.getDisplayMedia({audio:!1,video:!0}):navigator.mediaDevices.getUserMedia({audio:"audio"===e&&{...p&&{echoCancellation:!0},...m&&{noiseSuppression:!0}},video:"video"===e&&{facingMode:t}})}async function A(e,t=void 0){if(!y)return;const a="audio"===e?y.streams.ownAudio:"video"===e?y.streams.ownVideo:y.streams.ownPresentation;if(!a)return;const n=a.getTracks()[0];if(!n)return;const i=y.connection.getSenders().find((e=>n.id===e.track?.id));if(i){t=void 0===t?!n.enabled:t;try{if(t&&!n.enabled){const t=await B(e);t.getTracks()[0].onended=()=>{A(e,!1)},await i.replaceTrack(t.getTracks()[0]),"audio"===e?y.streams.ownAudio=t:"video"===e?(y.streams.ownVideo=t,y.facingMode="user"):y.streams.ownPresentation=t,"video"!==e&&"presentation"!==e||A("video"===e?"presentation":"video",!1)}else if(!t&&n.enabled){n.stop();const t="audio"===e?y.silence:"video"===e?y.blackVideo:y.blackPresentation;if(!t)return;await i.replaceTrack(t.getTracks()[0]),"audio"===e?y.streams.ownAudio=t:"video"===e?y.streams.ownVideo=t:y.streams.ownPresentation=t}x(),U()}catch(e){console.error(e)}}}function _(){y&&(y.streams.ownVideo?.getTracks().forEach((e=>e.stop())),y.streams.ownPresentation?.getTracks().forEach((e=>e.stop())),y.streams.ownAudio?.getTracks().forEach((e=>e.stop())),y.dataChannel.close(),y.connection.close(),y=void 0)}function U(){if(!y)return;const{emitSignalingData:e,streams:t}=y;e({"@type":"MediaState",videoRotation:0,isMuted:!t.ownAudio?.getTracks()[0].enabled,isBatteryLow:!0,videoState:t.ownVideo?.getTracks()[0].enabled?"active":"inactive",screencastState:t.ownPresentation?.getTracks()[0].enabled?"active":"inactive"})}function $(e){if(!y||y.isOutgoing)return e;const{payloadTypes:t}=e,a=t.findIndex((e=>"VP8"===e.name)),n=t[a],i=t.findIndex((e=>Number(e.parameters?.apt)===n.id));return e.payloadTypes=[t[a],t[i]],e}function D(e){if(!y)return;const{emitSignalingData:t}=y;e.ssrc&&e["ssrc-groups"]&&e["ssrc-groups"][0]&&e["ssrc-groups"][1]&&t({"@type":"InitialSetup",fingerprints:e.fingerprints,ufrag:e.ufrag,pwd:e.pwd,audio:{ssrc:r(e.ssrc).toString(),ssrcGroups:[],payloadTypes:e.audioPayloadTypes,rtpExtensions:e.audioExtmap},video:$({ssrc:r(e["ssrc-groups"][0].sources[0]).toString(),ssrcGroups:[{semantics:e["ssrc-groups"][0].semantics,ssrcs:e["ssrc-groups"][0].sources.map(r)}],payloadTypes:e.videoPayloadTypes,rtpExtensions:e.videoExtmap}),screencast:$({ssrc:r(e["ssrc-groups"][1].sources[0]).toString(),ssrcGroups:[{semantics:e["ssrc-groups"][1].semantics,ssrcs:e["ssrc-groups"][1].sources.map(r)}],payloadTypes:e.screencastPayloadTypes,rtpExtensions:e.screencastExtmap})})}async function L(e){if(y&&y.connection)switch(e["@type"]){case"MediaState":y.mediaState=e,x(),U();break;case"Candidates":{const{pendingCandidates:t,gotInitialSetup:a}=y;e.candidates.forEach((e=>{t.push(e.sdpString)})),a&&await j();break}case"InitialSetup":{const{connection:t,isOutgoing:a}=y;if(!t)return;const n={transport:{candidates:[],ufrag:e.ufrag,pwd:e.pwd,fingerprints:e.fingerprints,"rtcp-mux":!1,xmlns:""},sessionId:Date.now(),ssrcs:[e.audio&&{isVideo:!1,isMain:!1,userId:"123",endpoint:"0",mid:"0",sourceGroups:[{sources:[e.audio.ssrc]}]},e.video&&{isVideo:!0,isPresentation:!1,isMain:!1,userId:"123",endpoint:"1",mid:"1",sourceGroups:e.video.ssrcGroups.map((e=>({semantics:e.semantics,sources:e.ssrcs})))},e.screencast&&{isVideo:!0,isPresentation:!0,isMain:!1,userId:"123",endpoint:"2",mid:"2",sourceGroups:e.screencast.ssrcGroups.map((e=>({semantics:e.semantics,sources:e.ssrcs})))}],audioPayloadTypes:e.audio.payloadTypes?.map(l)||[],audioExtensions:e.audio.rtpExtensions,videoPayloadTypes:$(e.video).payloadTypes?.map(l)||[],videoExtensions:e.video.rtpExtensions};if(await t.setRemoteDescription({sdp:f(n,a,void 0,!0),type:a?"answer":"offer"}),y.conference=n,!a){const e=await t.createAnswer();await t.setLocalDescription(e),D(g(t.localDescription,!0))}y.gotInitialSetup=!0,await j();break}}}async function j(){if(!y)return;const{pendingCandidates:e,connection:t}=y;e.length&&(await Promise.all(e.map((e=>async function(e,t){try{await e.addIceCandidate({candidate:t,sdpMLineIndex:0})}catch(e){console.error(e)}}(t,e)))),y.pendingCandidates=[])}async function F(e,t){const a=await e.createOffer(t);await e.setLocalDescription(a),D(g(e.localDescription,!0))}var H=a(65054),K=a(60782),z=a(92387),J=a(33555),X=a(11302),q=a(78958),Y=a(44271),W=a(7054),Q=a(42431),ee=a(27225);(0,J.iw)("leaveGroupCall",(async(e,t,a)=>{const{isFromLibrary:i,shouldDiscard:o,shouldRemove:s,rejoin:r,isPageUnload:c,tabId:l=(0,H._w)()}=a||{},d=(0,Q.mU)(e);d&&(e=(0,q.Ic)(e,{connectionState:"disconnected"},d.participantsCount-1),e={...e,groupCalls:{...e.groupCalls,activeGroupCallId:void 0}},(0,J.R3)(e),await(0,z.t9)("leaveGroupCall",{call:d,isPageUnload:c}),await(0,z.t9)("abortRequestGroup","call"),o&&await(0,z.t9)("discardGroupCall",{call:d}),e=(0,J.Rd)(),s&&(e=(0,q.dc)(e,d.id)),(0,n.Mt)(),(0,J.R3)(e),t.toggleGroupCallPanel({force:void 0,tabId:l}),i||M(),t.afterHangUp(),r&&t.requestMasterAndJoinGroupCall({...r,tabId:l}))})),(0,J.iw)("toggleGroupCallVideo",(async e=>{const t=(0,Q.mU)(e),a=(0,W.dyD)(e,e.currentUserId);a&&t&&(await N("video"),await(0,z.t9)("editGroupCallParticipant",{call:t,videoStopped:!S("video"),participant:a}))})),(0,J.iw)("requestToSpeak",((e,t,a)=>{const{value:n}=a||{value:!0},i=(0,Q.mU)(e),o=(0,W.dyD)(e,e.currentUserId);o&&i&&(0,z.t9)("editGroupCallParticipant",{call:i,raiseHand:n,participant:o})})),(0,J.iw)("setGroupCallParticipantVolume",((e,t,a)=>{const{participantId:n,volume:i}=a,s=(0,Q.mU)(e),r=(0,W.dyD)(e,n);r&&s&&(E(n,Math.floor(i/o.Ro)/100),(0,z.t9)("editGroupCallParticipant",{call:s,volume:Number(i),participant:r}))})),(0,J.iw)("toggleGroupCallMute",(async(e,t,a)=>{const{participantId:n,value:i}=a||{},o=(0,Q.mU)(e),s=(0,W.dyD)(e,n||e.currentUserId);if(!s||!o)return;const r=void 0===i?S("audio",s.id):i;n?E(n,r?0:1):await N("audio"),await(0,z.t9)("editGroupCallParticipant",{call:o,muted:r,participant:s})})),(0,J.iw)("toggleGroupCallPresentation",(async(e,t,a)=>{const n=(0,Q.mU)(e),i=(0,W.dyD)(e,e.currentUserId);if(i&&n){if(void 0!==a?.value?a?.value:!S("presentation")){const e=await async function(){if(P)try{const e=await I("presentation");if(!e)return;return e.getTracks()[0].onended=()=>{P&&P.myId&&(delete P.streams?.[P.myId].presentation,k(P.myId),b())},await new Promise((t=>{const{connection:a,dataChannel:n}=O([e],t,!0);P={...P,screenshareConnection:a,screenshareDataChannel:n}}))}catch(e){return}}();if(!e)return;await(0,z.t9)("joinGroupCallPresentation",{call:n,params:e})}else await N("presentation",!1),await(0,z.t9)("leaveGroupCallPresentation",{call:n});await(0,z.t9)("editGroupCallParticipant",{call:n,presentationPaused:!S("presentation"),participant:i})}})),(0,J.iw)("connectToActiveGroupCall",(async(e,t,a)=>{const{tabId:i=(0,H._w)()}=a||{},o=(0,Q.mU)(e);if(!o)return;if("discarded"===o.connectionState)return void t.showNotification({message:"This voice chat is not active",tabId:i});const s=(0,n.FF)(),r=(0,n.NH)();if(!s||!r)return;const{currentUserId:c}=e;if(!c)return;const l=await function(e,t,a,n){if(P)throw Error("Already in call");T("connecting");const i=new MediaStream;return a.srcObject=i,(0,Z.Z)(a),P={onUpdate:n,participants:[],myId:e,speaking:{},silence:v(t),black:h({width:640,height:480}),analyserInterval:setInterval(V,1e3),audioElement:a,audioContext:t,mediaStream:i,lastMid:3},I("audio"),new Promise((e=>{P={...P,...O([P.silence,P.black],e)}}))}(c,r,s,t.apiUpdate),d=await(0,z.t9)("joinGroupCall",{call:o,params:l,inviteHash:o.inviteHash});if(e=(0,J.Rd)(),!d)return t.showNotification({message:"Failed to join voice chat",tabId:i}),void t.leaveGroupCall({tabId:i});if(t.loadMoreGroupCallParticipants(),o.chatId){e=(0,J.Rd)();const a=(0,W.Z1J)(e,o.chatId);if(!a)return;await(0,ee.ft)(e,t,a,i)}})),(0,J.iw)("connectToActivePhoneCall",(async(e,t)=>{const{phoneCall:a}=e;if(!a)return;const n=(0,Q.fu)(e);if(!n)return;const i=await(0,z.t9)("getDhConfig");if(!i)return;await(0,z.t9)("createPhoneCallState",[!0]);const o=await(0,z.t9)("requestPhoneCall",[i]),s=await(0,z.t9)("requestCall",{user:n,gAHash:o,isVideo:a.isVideo});s?(e=(0,J.Rd)(),e=(0,X.Sh)(e,(0,K.ee)(s.users,"id")),(0,J.R3)(e)):"hangUp"in t&&t.hangUp({tabId:(0,H._w)()})})),(0,J.iw)("acceptCall",(async e=>{const{phoneCall:t}=e;if(!t)return;const a=await(0,z.t9)("getDhConfig");if(!a)return;await(0,z.t9)("createPhoneCallState",[!1]);const n=await(0,z.t9)("acceptPhoneCall",[a]),i=await(0,z.t9)("acceptCall",{call:t,gB:n});i&&(e=(0,J.Rd)(),e=(0,X.Sh)(e,(0,K.ee)(i.users,"id")),(0,J.R3)(e))})),(0,J.iw)("sendSignalingData",((e,t,a)=>{const{phoneCall:n}=e;if(!n)return;const i=JSON.stringify(a);(async()=>{const e=await(0,z.t9)("encodePhoneCallData",[i]);e&&(0,z.t9)("sendSignalingData",{data:e,call:n})})()})),(0,J.iw)("closeCallRatingModal",((e,t,a)=>{const{tabId:n=(0,H._w)()}=a||{};return(0,Y.i)(e,{ratingPhoneCall:void 0},n)})),(0,J.iw)("setCallRating",((e,t,a)=>{const{rating:n,comment:i,tabId:o=(0,H._w)()}=a,{ratingPhoneCall:s}=(0,W.jUK)(e,o);if(s)return(0,z.t9)("setCallRating",{call:s,rating:n,comment:i}),(0,Y.i)(e,{ratingPhoneCall:void 0},o)})),(0,J.iw)("hangUp",((e,t,a)=>{const{isPageUnload:n,tabId:i=(0,H._w)()}=a||{},{phoneCall:o}=e;if(o){if("discarded"===o.state)return(0,z.t9)("destroyPhoneCallState"),_(),e={...e,phoneCall:void 0},(0,J.R3)(e),t.toggleGroupCallPanel({force:void 0,tabId:i}),void t.afterHangUp();if((0,z.t9)("destroyPhoneCallState"),_(),(0,z.t9)("discardCall",{call:o,isPageUnload:n}),"requesting"===o.state)return e={...e,phoneCall:void 0},(0,J.R3)(e),t.toggleGroupCallPanel({force:void 0,tabId:i}),void t.afterHangUp();setTimeout((()=>{e=(0,J.Rd)(),e={...e,phoneCall:void 0},(0,J.R3)(e),t.toggleGroupCallPanel({force:void 0,tabId:i}),t.afterHangUp()}),500)}}));var te=a(59692);const ae=new Uint16Array([55357,56841,55357,56845,55357,56859,55357,56877,55357,56881,55357,56865,55357,56846,55357,56884,55357,56885,55357,56840,55357,56876,55357,56839,55357,56847,55357,56430,55357,56439,55357,56450,55357,56438,55357,56424,55357,56425,55357,56436,55357,56437,55357,56891,55357,56893,55357,56896,55357,56442,55357,56904,55357,56905,55357,56906,55357,56448,55357,56445,55357,56489,55357,56613,55357,56485,55357,56484,55357,56386,55357,56384,55357,56387,55357,56389,55357,56388,55357,56397,55357,56398,55357,56396,55357,56394,9996,9995,55357,56400,55357,56390,55357,56391,55357,56393,55357,56392,55357,56911,55357,56399,55357,56490,55357,57014,55356,57283,55357,56451,55357,56427,55357,56426,55357,56428,55357,56429,55357,56453,55356,57257,55357,56401,55357,56402,55357,56415,55357,56414,55357,56416,55357,56405,55357,56407,55357,56406,55357,56409,55357,56412,55357,56403,55356,57216,55357,56452,55357,56475,55357,56473,55357,56476,55357,56474,55357,56461,55357,56462,55357,56374,55357,56378,55357,56369,55357,56365,55357,56377,55357,56368,55357,56376,55357,56367,55357,56360,55357,56379,55357,56375,55357,56366,55357,56343,55357,56372,55357,56337,55357,56344,55357,56380,55357,56359,55357,56357,55357,56340,55357,56333,55357,56354,55357,56347,55357,56349,55357,56348,55357,56350,55357,56332,55357,56345,55357,56346,55357,56351,55357,56364,55357,56331,55357,56336,55357,56330,55357,56363,55356,57152,55356,57145,55356,57147,55356,57153,55356,57150,55356,57156,55356,57141,55356,57140,55356,57139,55356,57118,55356,57114,55356,57113,55356,57102,55356,57099,9889,9748,10052,9924,55356,57088,55356,57096,55356,57098,55356,57235,55356,57222,55356,57219,55357,56443,55356,57221,55356,57220,55356,57217,55356,57224,55357,56622,55356,57253,55357,56567,55357,56511,55357,56507,9742,55357,56545,55357,56570,55357,56571,55357,56585,55357,56596,9203,9200,8986,55357,56594,55357,56593,55357,56590,55357,56481,55357,56614,55357,56588,55357,56587,55357,57023,55357,57021,55357,56615,55357,56616,55357,57002,55357,57004,55357,56483,55357,56619,55357,56618,55357,56458,55357,56457,55357,56496,55357,56501,55357,56499,9993,55357,56555,55357,56550,55357,56517,55357,56513,9986,55357,56524,55357,56526,10002,9999,55357,56528,55357,56538,55357,56620,55357,56621,55356,57256,55356,57260,55356,57252,55356,57255,55356,57269,55356,57273,55356,57275,55356,57274,55356,57272,55357,56446,55356,57262,55356,56527,55356,57266,55356,57263,55356,57288,55356,57280,9917,9918,55356,57278,55356,57265,55356,57289,55356,57267,55356,57281,55356,57287,55356,57286,55356,57290,55356,57284,9749,55356,57212,55356,57210,55356,57207,55356,57204,55356,57173,55356,57172,55356,57183,55356,57175,55356,57201,55356,57178,55356,57180,55356,57185,55356,57203,55356,57182,55356,57193,55356,57190,55356,57218,55356,57200,55356,57194,55356,57195,55356,57197,55356,57199,55356,57166,55356,57167,55356,57162,55356,57163,55356,57170,55356,57159,55356,57161,55356,57171,55356,57169,55356,57164,55356,57168,55356,57165,55356,57158,55356,57157,55356,57149,55356,57313,55356,57317,55356,57318,9962,55356,57328,9978,55356,57325,55357,56827,55357,56829,55356,57248,55356,57249,9970,55356,57250,55357,56994,55357,56996,9875,55357,56960,9992,55357,56961,55357,56962,55357,56971,55357,56974,55357,56972,55357,56985,55357,56983,55357,56981,55357,56987,55357,57e3,55357,56980,55357,56978,55357,56977,55357,57010,55357,56992,55357,56988,55357,56998,9888,55357,56999,9981,55356,57264,55357,56831,55356,57258,55356,57261,55356,56815,55356,56821,55356,56816,55356,56823,55356,56809,55356,56810,55356,56808,55356,56819,55356,56826,55356,56824,55356,56811,55356,56823,55356,56810,55356,56824,55356,56814,55356,56825,55356,56823,55356,56826,55356,56812,55356,56807,49,8419,50,8419,51,8419,52,8419,53,8419,54,8419,55,8419,56,8419,57,8419,48,8419,55357,56607,10071,10067,9829,9830,55357,56495,55357,56599,55357,56625,55357,56628,55357,56629,55357,56630,55357,56631]),ne=[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,87,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,256,258,259,260,261,262,264,266,268,270,272,274,276,278,280,282,284,286,288,290,292,294,295,297,299,301,303,305,306,307,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,351,353,355,357,359,360,362,364,365,366,368,370,372,374,376,378,380,382,384,386,388,390,392,394,396,398,400,402,404,406,407,408,410,412,414,416,418,420,422,424,426,427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479,481,483,485,487,489,491,493,495,497,499,501,503,505,507,508,510,511,513,515,517,519,521,522,524,526,528,529,531,532,534,536,538,540,542,544,546,548,550,552,554,556,558,560,562,564,566,567,569,570,572,574,576,578,582,586,590,594,598,602,606,610,614,618,620,622,624,626,628,630,632,634,636,638,640,641,642,643,644,646,648,650,652,654,656,658];(0,J.iw)("apiUpdate",((e,t,a)=>{const{activeGroupCallId:n}=e.groupCalls;switch(a["@type"]){case"updateGroupCallLeavePresentation":t.toggleGroupCallPresentation({value:!1});break;case"updateGroupCallStreams":if(!a.userId||!n)break;if(!(0,Q.GU)(e,n,a.userId))break;return(0,q.B6)(e,n,a.userId,(0,K.CE)(a,["@type","userId"]));case"updateGroupCallConnectionState":if(!n)break;if("disconnected"===a.connectionState){"leaveGroupCall"in t&&t.leaveGroupCall({isFromLibrary:!0,tabId:(0,H._w)()});break}return(0,q.AH)(e,n,{connectionState:a.connectionState,isSpeakerDisabled:a.isSpeakerDisabled});case"updateGroupCallParticipants":{const{groupCallId:e,participants:t}=a;n===e&&R(t);break}case"updateGroupCallConnection":{if(a.data.stream){t.showNotification({message:"Big live streams are not yet supported",tabId:(0,H._w)()}),"leaveGroupCall"in t&&t.leaveGroupCall({tabId:(0,H._w)()});break}!async function(e,t){if(!P)return;const a=t?P.screenshareConference:P.conference,n=t?P.screenshareConnection:P.connection;if(!a||!n||!a.ssrcs)return;const i=Date.now(),o={...a,transport:e.transport,sessionId:i,audioExtensions:e.audio?.["rtp-hdrexts"],audioPayloadTypes:e.audio?.["payload-types"],videoExtensions:e.video?.["rtp-hdrexts"],videoPayloadTypes:e.video?.["payload-types"]};P={...P,...t?{screenshareConference:o}:{conference:o}};try{await n.setRemoteDescription({type:"answer",sdp:f(o,!0,t)})}catch(e){console.error(e)}}(a.data,a.presentation);const n=(0,Q.mU)(e);n?.participants&&Object.keys(n.participants).length>0&&R(Object.values(n.participants));break}case"updatePhoneCallMediaState":return{...e,phoneCall:{...e.phoneCall,...(0,K.CE)(a,["@type"])}};case"updatePhoneCall":{if(!i.Bi)return;const{phoneCall:n,currentUserId:s}=e,r={...n,...a.call},c=n?.adminId===s;if(e={...e,phoneCall:r},(0,J.R3)(e),e=(0,J.Rd)(),n&&n.id&&r.id!==n.id)return void("discarded"!==r.state&&(0,z.t9)("discardCall",{call:r,isBusy:!0}));const{accessHash:l,state:d,connections:u,gB:p}=r;if(("active"===d||"accepted"===d)&&(o=r.protocol,!o?.libraryVersions.some((e=>"4.0.0"===e||"4.0.1"===e)))){const a=(0,Q.fu)(e);return"hangUp"in t&&t.hangUp({tabId:(0,H._w)()}),void t.showNotification({message:te.Iu("VoipPeerIncompatible",a?.firstName),tabId:(0,H._w)()})}if("discarded"===d){if(!n)return;return(0,Y.i)(e,{...r.needRating&&{ratingPhoneCall:r},isCallPanelVisible:void 0},(0,H._w)())}return"accepted"===d&&l&&p?(async()=>{const{gA:t,keyFingerprint:a,emojis:n}=await(0,z.t9)("confirmPhoneCall",[p,ae,ne]),i={...(e=(0,J.Rd)()).phoneCall,emojis:n};e={...e,phoneCall:i},(0,J.R3)(e);const o=await(0,z.t9)("confirmCall",{call:r,gA:t,keyFingerprint:a});o&&(e=(0,J.Rd)(),e=(0,X.Sh)(e,(0,K.ee)(o.users,"id")),(0,J.R3)(e))})():"active"===d&&u&&"active"!==n?.state&&(c||((0,z.t9)("receivedCall",{call:r}),(async()=>{const{emojis:t}=await(0,z.t9)("confirmPhoneCall",[r.gAOrB,ae,ne]),a={...(e=(0,J.Rd)()).phoneCall,emojis:t};e={...e,phoneCall:a},(0,J.R3)(e)})()),async function(e,t,a,n,i,o){const s=new RTCPeerConnection({iceServers:e.map((e=>({urls:[e.isTurn&&`turn:${e.ip}:${e.port}`,e.isStun&&`stun:${e.ip}:${e.port}`].filter(Boolean),username:e.username,credentialType:"password",credential:e.password}))),iceTransportPolicy:i?"all":"relay",bundlePolicy:"max-bundle",iceCandidatePoolSize:10});s.onicecandidate=e=>{e.candidate&&t({"@type":"Candidates",candidates:[{sdpString:e.candidate.candidate}]})},s.onconnectionstatechange=()=>{o({"@type":"updatePhoneCallConnectionState",connectionState:s.connectionState})},s.ontrack=e=>{if(!y)return;const t=e.streams[0];"audio"===e.track.kind?(y.audio.srcObject=t,y.audio.play().catch(),y.streams.audio=t):"1"===e.transceiver.mid?y.streams.video=t:y.streams.presentation=t,x()},s.oniceconnectionstatechange=async e=>{switch(s.iceConnectionState){case"disconnected":case"failed":a&&await F(s,{offerToReceiveAudio:!0,offerToReceiveVideo:!0,iceRestart:!0})}};const r=v(new AudioContext),c=h({width:640,height:480}),l=h({width:640,height:480});s.addTrack(r.getTracks()[0],r),s.addTrack(c.getTracks()[0],c),s.addTrack(l.getTracks()[0],l);const d=s.createDataChannel("data",{id:0,negotiated:!0});d.onmessage=e=>{L(JSON.parse(e.data))};const u=new Audio;y={audio:u,connection:s,emitSignalingData:t,isOutgoing:a,pendingCandidates:[],onUpdate:o,streams:{ownVideo:c,ownAudio:r,ownPresentation:l},mediaState:{isBatteryLow:!1,screencastState:"inactive",videoState:"inactive",videoRotation:0,isMuted:!0},blackVideo:c,blackPresentation:l,silence:r,dataChannel:d};try{A("audio",!0)}catch(e){console.error(e)}a&&await F(s,{offerToReceiveAudio:!0,offerToReceiveVideo:!0})}(u,t.sendSignalingData,c,Boolean(r?.isVideo),Boolean(r.isP2pAllowed),t.apiUpdate)),e}case"updatePhoneCallConnectionState":{const{connectionState:n}=a;return e.phoneCall?"closed"===n||"disconnected"===n||"failed"===n?void("hangUp"in t&&t.hangUp({tabId:(0,H._w)()})):{...e,phoneCall:{...e.phoneCall,isConnected:"connected"===n}}:e}case"updatePhoneCallSignalingData":{const{phoneCall:t}=e;if(!t)break;(0,z.t9)("decodePhoneCallData",[a.data])?.then(L);break}}var o}));var ie=a(60748),oe=a(46752),se=a(42797),re=a(60706),ce=a(3657),le=a(59107),de=a(25190),ue=a(80498),pe=a(87204),me=a(78722),ge=a(231),fe=a(14605),ve=a(41151),he=a(34563),Ce=a(27407),Ze=a(21273),Pe=a(32340);function ye(e){return Math.floor((e.volume||o.aCB)/o.Ro).toString()}var be=a(17240),we=a(12644),Ee=a(70172),Se=a(2153),ke=a(31876),Ie=a(89945),Ne=a(3927),Te=a(58912),Me=a(22275),Ve=a(52328),Re=a(58964);const Ge=[0,17],Oe=[17,34],xe=(0,ie.X$)((0,J.c$)((e=>({isAdmin:(0,Q.Ht)(e)})))((({participant:e,onCloseAnimationEnd:t,onClose:a,isDropdownOpen:n,isAdmin:i,positionY:s,menuRef:r,positionX:c,style:l,transformOriginY:d,transformOriginX:u})=>{const{toggleGroupCallMute:p,setGroupCallParticipantVolume:m,toggleGroupCallPanel:g,openChat:f,requestToSpeak:v}=(0,J.Sv)(),h=(0,le.Z)(),[C,Z,P]=(0,re.Z)(),y=e?.id,{isMutedByMe:b,isMuted:w,isSelf:E,canSelfUnmute:S}=e||{},k=Boolean(e?.raiseHandRating),I=!S&&w,[N,T]=(0,ie.eJ)(b?0:(e?.volume||o.aCB)/o.Ro),[M,V]=(0,ie.eJ)(!1),R=0===N,G=R?Ge:Oe;(0,ie.d4)((()=>{n||V(!1)}),[n]);const O=(0,de.Z)((e=>{T(e),V(0===e!==R)}));(0,ie.d4)((()=>{T(b?0:(e?.volume||o.aCB)/o.Ro)}),[y]);const x=function(e,t,a=[]){return(0,Ne.Z)((e=>{e()}),a,e,t)}(500),B=(0,de.Z)((e=>{e.stopPropagation(),Z(),a()})),A=(0,de.Z)((e=>{e.stopPropagation(),v({value:!1}),a()})),_=(0,de.Z)((t=>{t.stopPropagation(),a(),i?I&&O((e?.volume??o.aCB)/o.Ro):O(b?o.aCB/o.Ro:0),p({participantId:y,value:i?!I:!b})})),U=(0,de.Z)((e=>{e.stopPropagation(),g(),f({id:y}),a()}));return ie.ZP.createElement("div",null,ie.ZP.createElement(Ve.Z,{isOpen:n,positionX:c,positionY:s,transformOriginX:u,transformOriginY:d,style:l,ref:r,withPortal:!0,onClose:a,onCloseAnimationEnd:t,className:"participant-menu with-menu-transitions"},!E&&!I&&ie.ZP.createElement("div",{className:"group"},ie.ZP.createElement("div",{className:(0,oe.Z)("volume-control",N<50&&"low",N>=50&&N<100&&"medium",N>=100&&N<150&&"normal",N>=150&&"high")},ie.ZP.createElement("input",{type:"range",min:"0",max:"200",value:N,onChange:e=>{const t=Number(e.target.value);O(t),x((()=>{0===t?p({participantId:y,value:!0}):m({participantId:y,volume:Math.floor(t*o.Ro)})}))}}),ie.ZP.createElement("div",{className:"info"},ie.ZP.createElement(Te.Z,{tgsUrl:Ie.l.Speaker,play:!!M&&G.toString(),playSegment:G,size:24}),ie.ZP.createElement("span",null,N,"%")))),ie.ZP.createElement("div",{className:"group"},k&&E&&ie.ZP.createElement(Re.Z,{icon:"stop-raising-hand",onClick:A},h("VoipGroupCancelRaiseHand")),!E&&ie.ZP.createElement(Re.Z,{icon:"user",onClick:U},h("VoipGroupOpenProfile")),!E&&ie.ZP.createElement(Re.Z,{icon:w&&i&&I?"allow-speak":"microphone-alt",onClick:_},h(i?I?"VoipGroupAllowToSpeak":"VoipMute":b?"VoipGroupUnmuteForMe":"VoipGroupMuteForMe")),!E&&i&&ie.ZP.createElement(Re.Z,{icon:"delete-user",destructive:!0,onClick:B},h("VoipGroupUserRemove")))),!E&&i&&ie.ZP.createElement(Me.Z,{isOpen:C,userId:y,onClose:P}))}))),Be=(0,ie.X$)((({participant:e,noColor:t,className:a})=>{const{isMuted:n,isMutedByMe:i}=e,o=(e.amplitude||0)>d,s=Boolean(e.raiseHandRating),r=(0,pe.Z)(s),c=!Boolean(e?.canSelfUnmute)&&n,l=(0,pe.Z)(n),u=(0,ie.Ye)((()=>n&&!l?[43,64]:!n&&l?[22,42]:s&&!r?[65,84]:!c&&r?[0,21]:n?[22,23]:[43,44]),[n,c,s]),p=(0,ie.Ye)((()=>t?"#ffffff":s?"#4da6e0":c||i?"#ff706f":o?"#57bc6c":"#aaaaaa"),[t,s,c,i,o]);return ie.ZP.createElement(Te.Z,{tgsUrl:Ie.l.VoiceOutlined,play:u.toString(),playSegment:u,size:28,color:p,className:a,forceAlways:!0,nonInteractive:!0})})),Ae={root:"Wk7JwPx3",subtitle:"ShcCNemD",subtitleText:"UZLgp2cx",icon:"vRc6jhKf",subtitleBlue:"yA7bxEWw",subtitleRed:"DnuZwImI",subtitleGreen:"BkgYQGFq",avatar:"ouHUJ9ff"},_e=(0,ie.X$)((0,J.c$)(((e,{participant:t})=>({peer:(0,W.dyD)(e,t.id)||(0,W.Z1J)(e,t.id)})))((({participant:e,peer:t})=>{const a=(0,ie.sO)(null),n=(0,ie.sO)(null),i=(0,le.Z)(),{isSelf:s,isMutedByMe:r,isMuted:c,hasVideoStream:l,hasPresentationStream:u}=e,p=(e.amplitude||0)>d,m=Boolean(e.raiseHandRating),{isContextMenuOpen:g,contextMenuPosition:f,handleContextMenu:v,handleBeforeContextMenu:h,handleContextMenuClose:C,handleContextMenuHide:Z}=(0,be.Z)(a,s),P=(0,ie.I4)((()=>a.current),[]),y=(0,ie.I4)((()=>a.current.closest(".custom-scroll, .no-scrollbar")),[]),b=(0,ie.I4)((()=>n.current),[]),w=(0,ie.I4)((()=>({withPortal:!0})),[]),{positionX:E,positionY:S,transformOriginX:k,transformOriginY:I,style:N}=(0,we.Z)(f,P,y,b,w),T=Boolean(!c&&p&&e.volume&&e.volume!==o.aCB),[M,V]=(0,ie.Ye)((()=>r?[i("VoipGroupMutedForMe"),Ae.subtitleRed]:m?[i("WantsToSpeak"),Ae.subtitleBlue]:T?[i("SpeakingWithVolume",ye(e)).replace("%%","%"),Ae.subtitleGreen]:!c&&p?[i("Speaking"),Ae.subtitleGreen]:s?[i("ThisIsYou"),Ae.subtitleBlue]:e.about?[e.about,""]:[i("Listening"),Ae.subtitleBlue]),[r,m,T,c,p,s,e,i]);if(t)return ie.ZP.createElement(ke.Z,{leftElement:ie.ZP.createElement(Ee.Z,{peer:t,className:Ae.avatar}),rightElement:ie.ZP.createElement(Be,{participant:e,className:Ae.icon}),className:Ae.root,onClick:v,onMouseDown:h,onContextMenu:v,multiline:!0,ripple:!0,ref:a},ie.ZP.createElement(Se.Z,{peer:t,withEmojiStatus:!0,className:Ae.title}),ie.ZP.createElement("span",{className:(0,oe.Z)(Ae.subtitle,"subtitle",V)},u&&ie.ZP.createElement("i",{className:"icon icon-share-screen","aria-hidden":!0}),l&&ie.ZP.createElement("i",{className:"icon icon-video","aria-hidden":!0}),T&&ie.ZP.createElement("i",{className:"icon icon-speaker","aria-hidden":!0}),ie.ZP.createElement("span",{className:Ae.subtitleText},(0,Pe.Z)(M))),ie.ZP.createElement(xe,{participant:e,isDropdownOpen:g,positionX:E,positionY:S,transformOriginX:k,transformOriginY:I,style:N,onClose:C,onCloseAnimationEnd:Z,menuRef:n}))})));function Ue(e,t){return(0,K.aK)(!e.isMuted,!t.isMuted)||(0,K.aK)(e.presentation,t.presentation)||(0,K.aK)(e.video,t.video)||(0,K.aK)(e.raiseHandRating,t.raiseHandRating)}const $e=(0,ie.X$)((0,J.c$)((e=>{const{participantsCount:t,participants:a}=(0,Q.mU)(e)||{};return{participants:a,participantsCount:t||0}}))((({panelOffset:e,participants:t,participantsCount:a,isLandscape:n})=>{const{loadMoreGroupCallParticipants:i}=(0,J.Sv)(),o=(0,ie.Ye)((()=>Object.values(t||{}).sort(Ue).map((e=>e.id))),[t]),s=(0,de.Z)((()=>{i()})),[r,c]=(0,Ce.Z)(s,o,o.length>=a);return ie.ZP.createElement(Ze.Z,{items:r,onLoadMore:c,style:`transform: translateY(${e}px);`,className:(0,oe.Z)("npTa6CmI",!n&&"v7oB2HTv")},t&&r?.map((e=>t[e]&&ie.ZP.createElement(_e,{key:e,teactOrderKey:o.indexOf(e),participant:t[e]}))))})));var De=a(96264),Le=a(57710),je=a(9933),Fe=a(69118),He=a(96557),Ke=a(74607);const ze="eUXuK9Oz",Je="O2bTiH2E",Xe=(0,ie.X$)((0,J.c$)(((e,{participant:t})=>({user:t.isUser?(0,W.dyD)(e,t.id):void 0,chat:t.isUser?void 0:(0,W.Z1J)(e,t.id)})))((({layout:e,pinnedVideo:t,setPinned:a,canPin:n,className:s,participant:r,user:c,chat:l})=>{const u=(0,le.Z)(),p=(0,ie.sO)(null),m=(0,ie.sO)(null),g=(0,ie.sO)(null),{x:f,y:v,width:h,height:C,noAnimate:Z,isRemoved:P,type:y}=e,{isSelf:b,isMutedByMe:E,isMuted:S}=r,k=t?.id===r.id&&t?.type===y,I=(r.amplitude||0)>d,N=Boolean(r.raiseHandRating),T="video"===y&&r.isSelf,M=(0,ie.Ye)((()=>b?u("ThisIsYou"):E?u("VoipGroupMutedForMe"):N?u("WantsToSpeak"):S||!I?u("Listening"):r.volume&&r.volume!==o.aCB?u("SpeakingWithVolume",ye(r)).replace("%%","%"):u("Speaking")),[b,E,N,S,I,r,u]),V=(0,ie.sO)();P||(V.current=e);const{x:R,y:G,width:O,height:x}=V.current||{},[B,A,_,U]=P?[R,G,O,x]:[f,v,h,C],[$,D]=(0,ie.eJ)(!Z),L=w(c?.id||l.id),j="video"===y?L?.video:L?.presentation,F=(0,ie.sO)(j);j?.active&&j?.getVideoTracks()[0].enabled&&(F.current=j);const H=F.current,K=(0,de.Z)((()=>{const e=m.current;e&&(e.srcObject=null)}));(0,ie.d4)((()=>(H?.addEventListener("inactive",K),()=>{H?.removeEventListener("inactive",K)})),[K,H]),(0,ie.d4)((()=>{D(!1)}),[]);const[z,J]=(0,ie.eJ)(!0),X=(0,de.Z)((()=>{J(!1)}));(0,He.Z)((()=>{if(!H?.active)return;const e=m.current,t=g.current;(0,Le.WM)((()=>{t.width=e.videoWidth,t.height=e.videoHeight,t.getContext("2d").drawImage(e,0,0,t.width,t.height)}))}),1e3),(0,ie.d4)((()=>{const e=m.current,t=p.current;if(!e||!t||!H)return;const a=t.getContext("2d",{alpha:!1});if(!a)return;let n=!0;return(0,Le.WM)((()=>{n&&(t.width=16,t.height=16,a.filter="blur(2px)",(0,je.jt)((()=>!!n&&!!H.active&&(a.drawImage(e,0,0,e.videoWidth,e.videoHeight,0,0,t.width,t.height),i.vX||(0,De.Z)(a,0,0,t.width,t.height,2,2),!0)),Fe.T2))})),()=>{n=!1}}),[H]);const q=(0,ie.sO)(null),Y=(0,ie.sO)(null),{isContextMenuOpen:W,contextMenuPosition:Q,handleContextMenu:ee,handleContextMenuClose:te,handleContextMenuHide:ae}=(0,be.Z)(q,b),ne=(0,ie.I4)((()=>q.current),[]),se=(0,ie.I4)((()=>q.current.closest(".custom-scroll, .no-scrollbar")),[]),re=(0,ie.I4)((()=>Y.current),[]),ce=(0,ie.I4)((()=>({withPortal:!0})),[]),{positionX:ue,positionY:pe,transformOriginX:me,transformOriginY:fe,style:ve}=(0,we.Z)(Q,ne,se,re,ce),he=(0,ie.I4)((()=>{a(k?void 0:{id:c?.id||l.id,type:y})}),[l,k,a,y,c?.id]);return ie.ZP.createElement("div",{className:(0,oe.Z)("DKuzmnN7",($||P)&&"T_wodAHA",Z&&"yPCkJzpi",s,k&&"B4WZhF9P"),style:`--x: ${B}px; --y: ${A}px; --width: ${_}px; --height: ${U}px;`,ref:q,onContextMenu:ee,onDoubleClick:n?he:void 0},ie.ZP.createElement("div",{className:(0,oe.Z)("eBq1NoLo",I&&"h4NcT6OS")},z&&ie.ZP.createElement(Ke.Z,{className:(0,oe.Z)(ze,"XedVWQii")}),H&&ie.ZP.createElement("video",{className:(0,oe.Z)(ze,T&&Je),muted:!0,autoPlay:!0,playsInline:!0,srcObject:H,ref:m,onCanPlay:X}),ie.ZP.createElement("canvas",{className:(0,oe.Z)("eTpvBU_b eUXuK9Oz",T&&Je),ref:g}),ie.ZP.createElement("div",{className:"R5ULTrF9"},ie.ZP.createElement("canvas",{className:(0,oe.Z)("cjUWuViy",T&&Je),ref:p})),n&&ie.ZP.createElement(ge.Z,{round:!0,size:"smaller",ripple:!0,color:"translucent",className:"lPdblo0y",ariaLabel:u(k?"lng_group_call_context_unpin_camera":"lng_group_call_context_pin_camera"),onClick:he},ie.ZP.createElement("i",{className:(0,oe.Z)("icon",k?"icon-unpin":"icon-pin")})),ie.ZP.createElement("div",{className:"T1deCDSn"},ie.ZP.createElement("div",{className:"LzFFayK3"},ie.ZP.createElement(Se.Z,{peer:c||l,className:"RBwMAuKp"}),ie.ZP.createElement("div",{className:"z1ZZTsjC"},M)),ie.ZP.createElement(Be,{participant:r,className:"j1aDzn1H",noColor:!0}))),ie.ZP.createElement(xe,{participant:r,isDropdownOpen:W,positionX:ue,positionY:pe,transformOriginX:me,transformOriginY:fe,style:ve,onClose:te,onCloseAnimationEnd:ae,menuRef:Y}))}))),qe=()=>{navigator.vibrate?.(50)};var Ye=a(49204);const We=(0,ie.X$)((0,J.c$)((e=>{const t=(0,Q.mU)(e),{connectionState:a}=t||{},n=t&&(0,Q.GU)(e,t.id,e.currentUserId),{raiseHandRating:i,hasAudioStream:o,canSelfUnmute:s,isMuted:r}=n||{};return{connectionState:a||"discarded",hasRequestedToSpeak:Boolean(i),noAudioStream:!o,canSelfUnmute:s,isMuted:r}}))((({className:e,noAudioStream:t,canSelfUnmute:a,isMuted:n,connectionState:i})=>{const{toggleGroupCallMute:o,requestToSpeak:s,playGroupCallSound:r}=(0,J.Sv)(),c=(0,le.Z)(),l=(0,ie.sO)("up"),[d,u]=(0,ie.eJ)(!1),p="connected"!==i,m=!a&&n,g=(0,pe.Z)(m);(0,ie.d4)((()=>{g&&!m&&r({sound:"allowTalk"})}),[r,g,m]);const f=(0,ie.Ye)((()=>{if(d){const e=Math.floor(100*Math.random());return e<32?[0,120]:e<64?[120,240]:e<97?[240,420]:[420,540]}return!g&&m?t?[99,135]:[136,172]:g&&!m?[0,36]:m?[0,0]:t?[69,99]:[36,69]}),[g,d,t,m]),v=d?"HandFilled":"VoiceMini",h=(0,ie.I4)((()=>{qe(),o()}),[o]),C=(0,ie.I4)((()=>{if(m){if(d)return;return qe(),s(),u(!0),void setTimeout((()=>{u(!1)}),3e3)}l.current="down",t&&setTimeout((()=>{"down"===l.current&&(l.current="hold",h())}),200)}),[d,t,s,m,h]),Z=(0,ie.I4)((()=>{m||(h(),l.current="up")}),[m,h]);return ie.ZP.createElement(ge.Z,{round:!0,size:"default",className:(0,oe.Z)("lKdhQ5pw",!p&&t&&"bjKqp3SI",!p&&m&&"Ynow5UuE",e),onMouseDown:C,onMouseUp:Z,ariaLabel:c(n?"VoipUnmute":"VoipMute"),disabled:p},ie.ZP.createElement(Te.Z,{tgsUrl:Ie.l[v],size:36,play:f.toString(),playSegment:f,className:"Ea1XnQaX",forceAlways:!0}),ie.ZP.createElement(Ye.Z,{className:(0,oe.Z)("tyQNJC6B",p&&"LowChABq"),color:"white"}))}))),Qe={root:"OsO5GKfn",panelWrapper:"cUVoePr_",panel:"Thuz79M3",panelScrollTrigger:"zoK6Y6IS",panelHeader:"DMBtCL9Z",scrolled:"GdEH1Agb",fullscreen:"JJx0QI2w",landscape:"wamCuzMB",headerButton:"gmyieSid",firstButton:"hVnn6KBp",lastButton:"iy78A5rG",panelHeaderText:"TwEEA77i",title:"pNZ9skLf",bigger:"NumT3v5i",subtitle:"gmfUKabx",participants:"iTeC_RxH",participantVideos:"PZmKIdTl",addParticipantButton:"clmu2oBt",videos:"ATwoMlAV",mainVideoContainer:"hqFon3dV",videosHeader:"KPHc659W",appFullscreen:"cl2sfoBF",videosHeaderLastButton:"_t50HVNJ",videosContent:"oEEQZilE",actions:"uGzi9s97",actionButton:"foXbVcnN",destructive:"YIR9Z9CZ",canRequestToSpeak:"ZoiZQu_O",muted:"wpvv1V6m",portrait:"R6HQcMwx",noVideoParticipants:"aepCFyJQ",noSidebar:"XjgP21E6"},et=(0,ie.X$)((0,J.c$)(((e,{groupCallId:t})=>{const{connectionState:a,title:n,participants:i,participantsCount:o,chatId:s}=(0,Q.$5)(e,t)||{},r=s?(0,W.Z1J)(e,s):void 0;return{connectionState:a,title:n||r?.title,participantsCount:o,meParticipant:(0,Q.GU)(e,t,e.currentUserId),isCallPanelVisible:Boolean((0,W.jUK)(e).isCallPanelVisible),isAdmin:(0,Q.Ht)(e),participants:i,canInvite:(0,Q.LU)(e)}}))((({groupCallId:e,isCallPanelVisible:t,connectionState:a,participantsCount:n,title:i,meParticipant:o,isAdmin:s,participants:r,canInvite:c})=>{const{toggleGroupCallVideo:l,toggleGroupCallPresentation:d,leaveGroupCall:p,toggleGroupCallPanel:m,connectToActiveGroupCall:g,playGroupCallSound:f,createGroupCallInviteLink:v}=(0,J.Sv)(),h=(0,le.Z)(),C=(0,ie.sO)(null),Z=(0,ie.sO)(null),P=(0,ie.sO)(null),y=(0,ie.sO)(null),b=(0,ie.sO)(null),[w,E]=(0,ie.eJ)(!1),S=!t&&!w,{observe:k}=(0,ce.S1)({rootRef:b,throttleMs:200,isDisabled:!S}),I=!(0,ce.Op)(y,S?k:void 0),{isMobile:N,isLandscape:T}=(0,se.ZP)(),[M,V,R]=(0,re.Z)(),[G,O,x]=(0,re.Z)(!0),B=Boolean(M&&T),A=(0,ue.Ar)(),_=(0,ie.Ye)((()=>Object.values(r).find((({presentation:e})=>e))),[r]),U=(0,ie.Ye)((()=>Object.values(r).filter((({video:e,presentation:t})=>e||t)).flatMap((({id:e,video:t,presentation:a})=>(0,K.oA)([t?{id:e,type:"video"}:void 0,a?{id:e,type:"screen"}:void 0])))),[r]),$=U.length>0,D=i||h("VoipGroupVoiceChat"),L=h("Participants",n,"i"),[j,F,H]=(0,re.Z)(),[z,X]=(0,ie.eJ)(!1),[q,Y]=(0,ie.eJ)(!1),W=o?.hasVideoStream,Q=o?.hasPresentationStream,ee=o?.hasAudioStream,te="connected"!==a,ae=o?.canSelfUnmute,ne=!ae&&!ee;(0,ie.d4)((()=>{"connected"===a?f({sound:"join"}):"reconnecting"===a&&f({sound:"connecting"})}),[a]);const Ce=(0,de.Z)((()=>{H(),X(!1)})),Ze=(0,de.Z)((()=>{C.current&&!N&&(M?R():V())})),Pe=(0,de.Z)((()=>{G?x():O()})),ye=(0,de.Z)((()=>{m()})),be=(0,de.Z)((()=>{v()})),we=(0,de.Z)((()=>{l()}));(0,ie.d4)((()=>{g()}),[g,e]);const Ee=(0,de.Z)((()=>{!s||j?(f({sound:"leave"}),E(!0),H()):F()})),Se=(0,de.Z)((()=>{w&&p({shouldDiscard:q})})),ke=(0,de.Z)((()=>{d()})),Ie=U.length>1&&!N,Ne=B&&$,[Te,Me]=(0,ie.eJ)(void 0),{videoLayout:Ve,panelOffset:Re}=function({primaryContainerRef:e,secondaryContainerRef:t,videoParticipants:a,isLandscapeLayout:n,pinnedVideo:i}){const[o,s]=(0,ie.eJ)([]),[r,c]=(0,ie.eJ)(0),l=a.length,d=(0,pe.Z)(l),u=(0,pe.Z)(a),p=(0,ie.Ye)((()=>u?.filter((({id:e,type:t})=>!a.some((a=>a.id===e&&a.type===t))))),[u,a]),m=(0,de.Z)((()=>{const o=e.current,r=t.current;if(!r)return;const u=void 0!==d&&d>l?d-l:0,{x:m,y:g,width:f}=r.getBoundingClientRect(),v=[];if(void 0!==i||!o||!n){const e=!0;let t,r=!1,d=0,h=a;if(i&&o&&n&&(d=h.findIndex((({id:e,type:t})=>e===i.id&&t===i.type)),-1!==d)){const{x:e,y:a,width:n,height:s}=o.getBoundingClientRect(),{id:c,type:l}=i;t={x:e,y:a,width:n,height:s,participantId:c,type:l,orderKey:d},r=!0,h=h.filter((({id:e,type:t})=>e!==c||t!==i.type))}const C=r?l-1:l,Z=C%2==1,P=2,y=Math.ceil(C/P),b=(f-10*(P-1))/P,w=Math.max(0,Z?240+(y-1)*b+8*(y-1):y*b+8*(y-1));for(let t=0;t<C;t++){const a=Z&&0===t,n=a?f:b,i=a?240:b,o=Z&&0!==t?t+1:t,s=(e?0:m)+o%P*(n+10),r=(e?0:g)+(Z&&0!==t?248+(Math.floor(o/P)-1)*(i+8):Math.floor(o/P)*(i+8));v.push({x:s,y:r,width:n,height:i,shouldRemount:!e,isRemounted:e,noAnimate:!0,participantId:h[t].id,type:h[t].type,orderKey:t>=d?t+1:t})}if(t&&v.splice(d,0,t),p)for(let t=0;t<u;t++)v.push({x:0,y:0,width:0,height:0,isRemounted:e,isRemoved:!0,participantId:p[t].id,type:p[t].type,orderKey:t+l});return c(w),void s(v)}const{x:h,y:C,width:Z,height:P}=o.getBoundingClientRect(),y=function(e){return e>=25?5:e>=13?4:e>=7?3:e>=3?2:1}(l),b=Math.ceil(l/y),w=b*y>l,E=(Z-10*(y-1))/y,S=(P-8*(b-1))/b,k=E*(l%y);for(let e=0;e<l;e++){const t=Math.floor(e/y),n=h+e%y*(E+10)+(w&&t===b-1?(Z-k)/2:0),i=C+Math.floor(e/y)*(S+8);v.push({x:n,y:i,width:E,height:S,participantId:a[e].id,type:a[e].type,orderKey:e})}if(p)for(let e=0;e<u;e++)v.push({x:0,y:0,width:0,height:0,isRemoved:!0,participantId:p[e].id,type:p[e].type,orderKey:e+l});c(0),s(v)}));return(0,ie.d4)(m,[m,a,n,i]),(0,me.Z)(e,m,!e.current),(0,me.Z)(t,m,!t.current),{videoLayout:o,panelOffset:r}}({primaryContainerRef:Z,secondaryContainerRef:P,videoParticipants:U,isLandscapeLayout:B,pinnedVideo:Te}),Ge=(0,de.Z)((e=>{Me(e),e&&!M&&V()})),Oe=(0,de.Z)((()=>{_&&Me({id:_.id,type:"screen"})}));return(0,ie.d4)(Oe,[Oe,Boolean(_)]),(0,ie.d4)((()=>{Te&&(U.some((e=>e.type===Te.type&&e.id===Te.id))||Me(void 0))}),[Te,Ve,U]),ie.ZP.createElement(he.Z,{isOpen:S,onClose:m,className:(0,oe.Z)(Qe.root,(M||N)&&Qe.fullscreen,A&&Qe.appFullscreen,B&&Qe.landscape,!$&&Qe.noVideoParticipants,!B&&Qe.portrait,!G&&Ne&&Qe.noSidebar),dialogRef:C,onCloseAnimationEnd:Se},Ne&&ie.ZP.createElement("div",{className:Qe.videos},ie.ZP.createElement("div",{className:Qe.videosHeader},!N&&ie.ZP.createElement(ge.Z,{round:!0,size:"smaller",color:"translucent",onClick:Ze,className:(0,oe.Z)(Qe.headerButton,Qe.firstButton),ariaLabel:h(M?"AccExitFullscreen":"AccSwitchToFullscreen")},ie.ZP.createElement("i",{className:(0,oe.Z)("icon",M?"icon-smallscreen":"icon-fullscreen"),"aria-hidden":!0})),ie.ZP.createElement("h3",{className:(0,oe.Z)(Qe.title,Qe.bigger)},i||h("VoipGroupVoiceChat")),Ne&&!G&&ie.ZP.createElement(ge.Z,{round:!0,size:"smaller",color:"translucent",className:(0,oe.Z)(Qe.headerButton,Qe.videosHeaderLastButton),onClick:Pe,ariaLabel:h("AccDescrExpandPanel")},ie.ZP.createElement("i",{className:"icon icon-sidebar","aria-hidden":!0}))),ie.ZP.createElement("div",{className:Qe.videosContent,ref:Z})),ie.ZP.createElement("div",{className:Qe.panelWrapper,ref:b},ie.ZP.createElement("div",{className:(0,oe.Z)(Qe.panel,"custom-scroll")},ie.ZP.createElement("div",{className:Qe.panelScrollTrigger,ref:y}),ie.ZP.createElement("div",{className:(0,oe.Z)(Qe.panelHeader,I&&Qe.scrolled)},!Ne&&!N&&ie.ZP.createElement(ge.Z,{round:!0,size:"smaller",color:"translucent",ripple:!N,className:(0,oe.Z)(Qe.firstButton,Qe.headerButton),onClick:Ze,ariaLabel:h("AccSwitchToFullscreen")},ie.ZP.createElement("i",{className:"icon icon-fullscreen","aria-hidden":!0})),N&&ie.ZP.createElement(ge.Z,{round:!0,size:"smaller",color:"translucent",onClick:ye,className:(0,oe.Z)(Qe.headerButton,Qe.firstButton),ariaLabel:h("Close")},ie.ZP.createElement("i",{className:(0,oe.Z)("icon","icon-close"),"aria-hidden":!0})),Ne&&ie.ZP.createElement(ge.Z,{round:!0,size:"smaller",ripple:!N,className:(0,oe.Z)(Qe.firstButton,Qe.headerButton),color:"translucent",onClick:Pe,ariaLabel:h("AccDescrCollapsePanel")},ie.ZP.createElement("i",{className:"icon icon-sidebar","aria-hidden":!0})),ie.ZP.createElement("div",{className:Qe.panelHeaderText},ie.ZP.createElement("h3",{className:(0,oe.Z)(Qe.title,Ne&&Qe.bigger)},Ne?L:D),!Ne&&ie.ZP.createElement("span",{className:Qe.subtitle},L)),!Ne&&c&&ie.ZP.createElement(ge.Z,{round:!0,size:"smaller",ripple:!N,className:(0,oe.Z)(Qe.lastButton,Qe.headerButton),color:"translucent",onClick:be,ariaLabel:h("VoipGroupInviteMember")},ie.ZP.createElement("i",{className:"icon icon-add-user","aria-hidden":!0}))),ie.ZP.createElement("div",{className:Qe.participants},ie.ZP.createElement("div",{className:Qe.participantVideos,ref:P,style:`height: ${Re}px;`},Ve.map((e=>{const t=r[e.participantId];return e.isRemounted&&t?ie.ZP.createElement(Xe,{teactOrderKey:e.orderKey,key:`${e.participantId}_${e.type}`,layout:e,canPin:Ie,setPinned:Ge,pinnedVideo:Te,participant:t}):ie.ZP.createElement("div",{teactOrderKey:e.orderKey,key:`${e.participantId}_${e.type}`})}))),ie.ZP.createElement($e,{panelOffset:Re,isLandscape:Ne}))),ie.ZP.createElement(ve.Z,{key:"add-participant",isShown:Ne&&c,onClick:be,className:Qe.addParticipantButton,ariaLabel:h("VoipGroupInviteMember")},ie.ZP.createElement("i",{className:"icon icon-add-user-filled","aria-hidden":!0}))),ie.ZP.createElement("div",{className:Qe.mainVideoContainer},Ve.map((e=>{const t=r[e.participantId];return e.isRemounted||!t?ie.ZP.createElement("div",{teactOrderKey:e.orderKey,key:`${e.participantId}_${e.type}`}):ie.ZP.createElement(Xe,{teactOrderKey:e.orderKey,key:`${e.participantId}_${e.type}`,layout:e,canPin:Ie,setPinned:Ge,pinnedVideo:Te,participant:t,className:Qe.video})}))),ie.ZP.createElement("div",{className:Qe.actions},ie.ZP.createElement(ge.Z,{round:!0,size:"default",ripple:!0,className:(0,oe.Z)(Qe.actionButton,!ee&&Qe.muted,ne&&Qe.canRequestToSpeak),onClick:we,ariaLabel:h(W?"VoipStopVideo":"VoipStartVideo"),disabled:te},ie.ZP.createElement("i",{className:(0,oe.Z)("icon",W?"icon-video":"icon-video-stop"),"aria-hidden":!0})),ie.ZP.createElement(ge.Z,{round:!0,size:"default",ripple:!0,className:(0,oe.Z)(Qe.actionButton,!ee&&Qe.muted,ne&&Qe.canRequestToSpeak),onClick:ke,ariaLabel:h(Q?"lng_group_call_screen_share_stop":"lng_group_call_tooltip_screen"),disabled:te||!u},ie.ZP.createElement("i",{className:(0,oe.Z)("icon",Q?"icon-share-screen":"icon-share-screen-stop"),"aria-hidden":!0})),ie.ZP.createElement(We,{className:Qe.actionButton}),ie.ZP.createElement(ge.Z,{round:!0,size:"default",ripple:!0,className:(0,oe.Z)(Qe.actionButton,!ee&&Qe.muted,ne&&Qe.canRequestToSpeak),ariaLabel:h("lng_group_call_settings"),disabled:!0},ie.ZP.createElement("i",{className:"icon icon-settings-filled","aria-hidden":!0})),ie.ZP.createElement(ge.Z,{round:!0,size:"default",ripple:!0,className:(0,oe.Z)(Qe.actionButton,Qe.destructive),onClick:Ee,ariaLabel:h("lng_group_call_leave")},ie.ZP.createElement("i",{className:"icon icon-close","aria-hidden":!0}))),ie.ZP.createElement(he.Z,{isOpen:j,onClose:Ce,className:"error",title:h(z?"VoipGroupEndAlertTitle":"VoipGroupLeaveAlertTitle")},ie.ZP.createElement("p",null,h(z?"VoipGroupEndAlertText":"VoipGroupLeaveAlertText")),!z&&ie.ZP.createElement(fe.Z,{label:h("VoipGroupEndChat"),checked:q,onCheck:Y}),ie.ZP.createElement("div",{className:"dialog-buttons"},ie.ZP.createElement(ge.Z,{isText:!0,className:"confirm-dialog-button",onClick:Ee},h(z?"VoipGroupEnd":"VoipGroupLeave")),ie.ZP.createElement(ge.Z,{isText:!0,className:"confirm-dialog-button",onClick:Ce},h("Cancel")))))}))),tt=(0,ie.X$)((0,J.c$)((e=>{const t=(0,W.jUK)(e);return{groupCall:t.isMasterTab?(0,Q.mU)(e):void 0,isCallPanelVisible:t.isCallPanelVisible,phoneCallUser:t.isMasterTab?(0,Q.fu)(e):void 0}}))((({groupCall:e,phoneCallUser:t,isCallPanelVisible:a})=>{const{toggleGroupCallPanel:n}=(0,J.Sv)(),i=(0,le.Z)();if((0,ie.d4)((()=>(document.body.classList.toggle("has-call-header",Boolean(a)),window.electron?.setTrafficLightPosition(a?"lowered":"standard"),()=>{document.body.classList.toggle("has-call-header",!1),window.electron?.setTrafficLightPosition("standard")})),[a]),e||t)return ie.ZP.createElement("div",{className:(0,oe.Z)("ActiveCallHeader",a&&"open"),onClick:function(){n()}},ie.ZP.createElement("span",{className:"title"},t?.firstName||e?.title||i("VoipGroupVoiceChat")))})));var at=a(33323),nt=a(65326);const it=(0,ie.X$)((({onClick:e,label:t,customIcon:a,icon:n,iconClassName:i,className:o,isDisabled:s,isActive:r})=>ie.ZP.createElement("div",{className:"lBO3RZUM"},ie.ZP.createElement(ge.Z,{round:!0,className:(0,oe.Z)(o,"ch2sqAKW",r&&"OQxlsRp7"),onClick:e,disabled:s},a||ie.ZP.createElement("i",{className:(0,oe.Z)(i,"icon",`icon-${n}`)})),ie.ZP.createElement("div",{className:"aHguvLcL"},t)))),ot={root:"GNYRVAUg",blurred:"RBmbMiou","single-column":"O7cZE08z",singleColumn:"O7cZE08z",header:"GI6dY5aJ","close-button":"ULiJZuaP",closeButton:"ULiJZuaP","emojis-backdrop":"RFBKZpjx",emojisBackdrop:"RFBKZpjx",open:"zi1NlOXX",emojis:"DFco1VIN","emoji-tooltip":"MRIShZ3V",emojiTooltip:"MRIShZ3V","user-info":"eaUe2A0c",userInfo:"eaUe2A0c",buttons:"qIeflO02",leave:"hclywYYk",accept:"ln_ZBUHy","accept-icon":"cVRd3twS",acceptIcon:"cVRd3twS","main-video":"bGlBFSJq",mainVideo:"bGlBFSJq","second-video":"TOFu1n5x",secondVideo:"TOFu1n5x",visible:"LOnSFN9w",fullscreen:"Omg5T1o6"},st=(0,ie.X$)((0,J.c$)((e=>{const{phoneCall:t,currentUserId:a}=e,{isCallPanelVisible:n,isMasterTab:i}=(0,W.jUK)(e),o=(0,Q.fu)(e);return{isCallPanelVisible:Boolean(n),user:o,isOutgoing:t?.adminId===a,phoneCall:i?t:void 0}}))((({user:e,isOutgoing:t,phoneCall:a,isCallPanelVisible:n})=>{const o=(0,le.Z)(),{hangUp:s,requestMasterAndAcceptCall:r,playGroupCallSound:c,toggleGroupCallPanel:l,connectToActivePhoneCall:d}=(0,J.Sv)(),p=(0,ie.sO)(null),[m,g,f]=(0,re.Z)(),{isMobile:v}=(0,se.ZP)(),h=(0,ie.I4)((()=>{m?f():g()}),[f,m,g]),C=(0,ie.I4)((()=>{p.current&&(m?document.exitFullscreen().then(f):p.current.requestFullscreen().then(g))}),[f,m,g]);(0,ie.d4)((()=>{if(!i.t0)return;const e=p.current;return e?(e.addEventListener("fullscreenchange",h),()=>{e.removeEventListener("fullscreenchange",h)}):void 0}),[h]);const Z=(0,ie.I4)((()=>{l(),m&&f()}),[f,m,l]),P="discarded"===a?.state,b="busy"===a?.reason,w="requested"===a?.state&&!t,E=("requested"===a?.state||"waiting"===a?.state)&&t,S="active"===a?.state,k=a?.isConnected,[I,N,T]=(0,re.Z)(),M=(0,ie.I4)((()=>{N(),s()}),[s,N]);(0,ie.d4)((()=>{I?c({sound:"end"}):w?c({sound:"incoming"}):b?c({sound:"busy"}):P?c({sound:"end"}):E?c({sound:"ringing"}):k&&c({sound:"connect"})}),[b,P,w,E,k,c,I]),(0,ie.d4)((()=>{a?.id?T():d()}),[d,a?.id,T]);const V=(0,nt.Z)();(0,He.Z)(V,k?1e3:void 0);const R=(0,ie.Ye)((()=>{const e=a?.state;return I?o("lng_call_status_hanging"):b?"busy":"requesting"===e?o("lng_call_status_requesting"):"requested"===e?o(t?"lng_call_status_ringing":"lng_call_status_incoming"):"waiting"===e?o("lng_call_status_waiting"):"active"===e&&k?void 0:o("lng_call_status_exchanging")}),[b,k,I,t,o,a?.state]),G="active"===a?.videoState,O="active"===a?.screencastState,_=y?.streams,U=_?.ownAudio?.getTracks()[0].enabled,$=_?.ownPresentation?.getTracks()[0].enabled,D=_?.ownVideo?.getTracks()[0].enabled,[L,j,F]=(0,re.Z)(),[H,K,z]=(0,re.Z)(),X=(0,ie.I4)((()=>{$&&j(),D&&K(),setTimeout((async()=>{await A("presentation"),F(),z()}),250)}),[$,D,j,K,F,z]),q=(0,ie.I4)((()=>{D&&K(),$&&j(),setTimeout((async()=>{await A("video"),F(),z()}),250)}),[$,D,j,K,F,z]),Y=(0,ie.I4)((()=>{A("audio")}),[]),[W,Q,ee]=(0,re.Z)(),[te,ae,ne]=(0,re.Z)(),ce=(0,ie.I4)((()=>{ae(),async function(){if(!y||!y.facingMode)return;const e=y.streams.ownVideo;if(!e)return;const t=e.getTracks()[0];if(!t)return;const a=y.connection.getSenders().find((e=>t.id===e.track?.id));if(a){y.facingMode="environment"===y.facingMode?"user":"environment";try{const e=await B("video",y.facingMode);await a.replaceTrack(e.getTracks()[0]),y.streams.ownVideo=e,x()}catch(e){}}}(),setTimeout(ne,250)}),[ae,ne]),de=a?.startDate&&Number(new Date)/1e3-a.startDate;return(0,ie.d4)((()=>{"discarded"===a?.state&&setTimeout(s,250)}),[s,a?.reason,a?.state]),ie.ZP.createElement(he.Z,{isOpen:a&&"discarded"!==a?.state&&!n,onClose:Z,className:(0,oe.Z)(ot.root,v&&ot.singleColumn),dialogRef:p},ie.ZP.createElement(Ee.Z,{peer:e,size:"jumbo",className:G||O?ot.blurred:""}),"active"===a?.screencastState&&_?.presentation&&ie.ZP.createElement("video",{className:ot.mainVideo,muted:!0,autoPlay:!0,playsInline:!0,srcObject:_.presentation}),"active"===a?.videoState&&_?.video&&ie.ZP.createElement("video",{className:ot.mainVideo,muted:!0,autoPlay:!0,playsInline:!0,srcObject:_.video}),ie.ZP.createElement("video",{className:(0,oe.Z)(ot.secondVideo,!L&&$&&ot.visible,m&&ot.fullscreen),muted:!0,autoPlay:!0,playsInline:!0,srcObject:_?.ownPresentation}),ie.ZP.createElement("video",{className:(0,oe.Z)(ot.secondVideo,!H&&D&&ot.visible,m&&ot.fullscreen),muted:!0,autoPlay:!0,playsInline:!0,srcObject:_?.ownVideo}),ie.ZP.createElement("div",{className:ot.header},i.t0&&ie.ZP.createElement(ge.Z,{round:!0,size:"smaller",color:"translucent",onClick:C,ariaLabel:o(m?"AccExitFullscreen":"AccSwitchToFullscreen")},ie.ZP.createElement("i",{className:(0,oe.Z)("icon",m?"icon-smallscreen":"icon-fullscreen")})),ie.ZP.createElement(ge.Z,{round:!0,size:"smaller",color:"translucent",onClick:Z,className:ot.closeButton},ie.ZP.createElement("i",{className:"icon icon-close"}))),ie.ZP.createElement("div",{className:(0,oe.Z)(ot.emojisBackdrop,W&&ot.open),onClick:W?ee:Q},ie.ZP.createElement("div",{className:(0,oe.Z)(ot.emojis,W&&ot.open)},a?.isConnected&&a?.emojis&&(0,Pe.Z)(a.emojis,["emoji"])),ie.ZP.createElement("div",{className:(0,oe.Z)(ot.emojiTooltip,W&&ot.open)},o("CallEmojiKeyTooltip",e?.firstName).replace("%%","%"))),ie.ZP.createElement("div",{className:ot.userInfo},ie.ZP.createElement("h1",null,e?.firstName),ie.ZP.createElement("span",{className:ot.status},R||(0,at.k9)(de||0))),ie.ZP.createElement("div",{className:ot.buttons},ie.ZP.createElement(it,{onClick:Y,icon:"microphone",isDisabled:!S,isActive:U,label:o(U?"lng_call_mute_audio":"lng_call_unmute_audio")}),ie.ZP.createElement(it,{onClick:q,icon:"video",isDisabled:!S,isActive:D,label:o(D?"lng_call_stop_video":"lng_call_start_video")}),D&&(i.wZ||i.cj)&&ie.ZP.createElement(it,{onClick:ce,customIcon:ie.ZP.createElement(Te.Z,{tgsUrl:Ie.l.CameraFlip,playSegment:te?[0,10]:[0,1],size:32}),isDisabled:!S,label:o("VoipFlip")}),u&&ie.ZP.createElement(it,{onClick:X,icon:"share-screen",isDisabled:!S,isActive:$,label:o("lng_call_screencast")}),w&&ie.ZP.createElement(it,{onClick:r,icon:"phone-discard",isDisabled:P,label:o("lng_call_accept"),className:ot.accept,iconClassName:ot.acceptIcon}),ie.ZP.createElement(it,{onClick:M,icon:"phone-discard",isDisabled:P,label:o(w?"lng_call_decline":"lng_call_end_call"),className:ot.leave})))})));var rt=a(97687);const ct=(0,ie.X$)((({isOpen:e})=>{const{closeCallRatingModal:t,setCallRating:a}=(0,J.Sv)(),n=(0,ie.sO)(null),i=(0,le.Z)(),[o,s]=(0,ie.eJ)(),r=(0,ie.I4)((()=>{o?a({rating:o+1,comment:n.current?.value||""}):t()}),[t,o,a]),c=(0,ie.I4)((()=>{t()}),[t]);return ie.ZP.createElement(he.Z,{title:i("lng_call_rate_label"),className:"narrow",onClose:t,isOpen:e},ie.ZP.createElement("div",{className:"P7EfDKJN"},new Array(5).fill(void 0).map(((e,t)=>{const a=void 0!==o&&o>=t;return ie.ZP.createElement("i",{className:(0,oe.Z)("icon",a?"icon-favorite-filled":"icon-favorite",a&&"_XX6q8YW","t8LJLFSN"),onClick:(n=t,()=>s(o===n?void 0:n))});var n}))),ie.ZP.createElement(rt.Z,{ref:n,placeholder:i("lng_call_rate_comment"),className:(0,oe.Z)("EvL0WaKD",4!==o&&void 0!==o&&"v5hn1XvT")}),ie.ZP.createElement("div",{className:"dialog-buttons mt-2"},ie.ZP.createElement(ge.Z,{className:"confirm-dialog-button",isText:!0,onClick:r},i("Send")),ie.ZP.createElement(ge.Z,{className:"confirm-dialog-button",isText:!0,onClick:c},i("Cancel"))))}));(i.s$||i.cj)&&document.addEventListener("click",n.o5,{once:!0})}}]);
|
|
//# sourceMappingURL=9954.7a83eae09256aa21b092.js.map
|