TelegramPWA/dist/9954.f812ca56e8d765d22a04.js
Alexander Zinchuk 82e4483d02 [Build]
2024-01-12 13:09:26 +01:00

2 lines
64 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)},y=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}`:""}`)}))},Z=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(y),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(Z):c.filter((e=>"0"===e.mid||"1"===e.mid)).map(Z),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(Z),`${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),y=a(74753);let Z,P;function b(e){Z&&(Z.screenshareDataChannel?.close(),Z.screenshareConnection?.close(),e||Z.onUpdate?.({"@type":"updateGroupCallLeavePresentation"}))}function w(e){return Z?.streams?.[e]}function E(e,t){const a=Z?.participantFunctions?.[e];a&&a.setVolume?.(t)}function S(e,t){const a=t||Z?.myId,n=a&&w(a)?.[e];return!!n&&n.getTracks()[0]?.enabled}function k(e){Z?.onUpdate?.({"@type":"updateGroupCallStreams",userId:e,hasAudioStream:S("audio",e),hasVideoStream:S("video",e),hasPresentationStream:S("presentation",e),amplitude:Z.speaking?.[e]})}async function I(e,t="user"){if("audio"===e&&Z?.audioStream)return Z.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(Z&&"audio"===e&&(Z.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(!(Z&&Z.myId&&Z.connection&&Z.streams))return;const a=w(Z.myId)?.[e];if(!a)return;const n=a.getTracks()[0];if(!n)return;const i=[...Z.connection.getSenders(),...Z.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]),Z.streams[Z.myId][e]=t,"video"===e)Z.facingMode="user";else if("audio"===e){const{audioContext:e}=Z;if(!e)return;const a=Z.audioSource||e.createMediaStreamSource(t),n=Z.audioAnalyser||e.createAnalyser();n.minDecibels=-100,n.maxDecibels=-30,n.smoothingTimeConstant=.05,n.fftSize=1024,a.connect(n),Z={...Z,audioSource:a,audioAnalyser:n,participantFunctions:{...Z.participantFunctions,[Z.myId]:{...Z.participantFunctions?.[Z.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?Z.silence:Z.black;if(!t)return;await i.replaceTrack(t.getTracks()[0]),Z.streams[Z.myId][e]=t,"video"===e&&(Z.facingMode=void 0),"audio"!==e?n.stop():(Z.audioSource?.disconnect(),Z.audioAnalyser?.disconnect())}k(Z.myId),"presentation"!==e||t||b(!0)}catch(e){}}}function T(e){Z?.onUpdate?.({"@type":"updateGroupCallConnectionState",connectionState:e})}function M(){Z&&(Z.myId&&Z.streams?.[Z.myId]&&Object.values(Z.streams[Z.myId]||{}).forEach((e=>{e?.getTracks().forEach((e=>{e.stop()}))})),Z.audioStream?.getTracks().forEach((e=>{e.stop()})),b(!0),Z.dataChannel?.close(),Z.connection?.close(),T("disconnected"),Z.analyserInterval&&clearInterval(Z.analyserInterval),Z=void 0)}function V(){Z&&Z.participantFunctions&&Object.keys(Z.participantFunctions).forEach((e=>{const{getCurrentAmplitude:t}=Z.participantFunctions[Number(e)];if(t){const a=t(),n=Z.speaking[e]||0;Z.speaking[e]=a,(a>d&&n<=d||a<=d&&n>d)&&k(e)}}))}async function R(e){if(!Z)return;const{participants:t,conference:a,connection:n,myId:i}=Z;if(!(t&&a&&n&&a.ssrcs&&a.transport&&i))return;if(e.find((e=>e.isSelf&&e.source!==Z?.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||(Z.lastMid=Z.lastMid+1,a.ssrcs.push({userId:e.id,isMain:!1,endpoint:`audio${e.source}`,isVideo:!1,sourceGroups:[{sources:[e.source]}],mid:Z.lastMid.toString()})),i||r||!e.video||(Z.lastMid=Z.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:Z.lastMid.toString()})),s||l||!e.presentation||(Z.lastMid=Z.lastMid+1,a.ssrcs.push({isPresentation:!0,userId:e.id,isMain:!1,endpoint:e.presentation.endpoint,isVideo:!0,sourceGroups:e.presentation.sourceGroups,mid:Z.lastMid.toString()}))})),Z.updatingParticipantsQueue)return void Z.updatingParticipantsQueue.push(a);Z.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),Z.updatingParticipantsQueue.length>0)for(const e of Z.updatingParticipantsQueue){await n.setRemoteDescription({type:"offer",sdp:f(e)});const t=await n.createAnswer();await n.setLocalDescription(t),k(i)}Z.updatingParticipantsQueue=void 0}catch(e){console.error(e)}}function G(e){if(!(Z&&Z.audioElement&&Z.audioContext&&Z.mediaStream))return;const t=Z.conference?.ssrcs?.find((t=>t.endpoint===e.track.id));if(!t||!t.userId)return;const{userId:a,isPresentation:n}=t,i=Z.participants?.find((e=>e.id===a)),o="video"===e.track.kind?n?"presentation":"video":"audio";e.track.onended=()=>{delete Z?.streams?.[a][o],k(a)};const s=e.streams[0];if("audio"===e.track.kind){const{mediaStream:e}=Z,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(),Z={...Z,participantFunctions:{...Z.participantFunctions,[a]:{...Z.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)}}}}}Z={...Z,streams:{...Z.streams,[a]:{...Z.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(!Z)return;console.log("onnegotiationneeded");const{myId:i}=Z;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?Z.screenshareConference:Z.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));Z={...Z,...a?{screenshareConference:{...l,ssrcs:d}}:{conference:{...l,ssrcs:d}},streams:{...Z.streams,[i]:{...Z.streams?.[i],...u&&{audio:u},...!a&&p?{video:p}:{presentation:p}}}},k(i),t(s)},{connection:n,dataChannel:i}}function x(){P?.onUpdate({...P.mediaState,"@type":"updatePhoneCallMediaState"})}function _(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(!P)return;const a="audio"===e?P.streams.ownAudio:"video"===e?P.streams.ownVideo:P.streams.ownPresentation;if(!a)return;const n=a.getTracks()[0];if(!n)return;const i=P.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 _(e);t.getTracks()[0].onended=()=>{A(e,!1)},await i.replaceTrack(t.getTracks()[0]),"audio"===e?P.streams.ownAudio=t:"video"===e?(P.streams.ownVideo=t,P.facingMode="user"):P.streams.ownPresentation=t,"video"!==e&&"presentation"!==e||A("video"===e?"presentation":"video",!1)}else if(!t&&n.enabled){n.stop();const t="audio"===e?P.silence:"video"===e?P.blackVideo:P.blackPresentation;if(!t)return;await i.replaceTrack(t.getTracks()[0]),"audio"===e?P.streams.ownAudio=t:"video"===e?P.streams.ownVideo=t:P.streams.ownPresentation=t}x(),U()}catch(e){console.error(e)}}}function D(){P&&(P.streams.ownVideo?.getTracks().forEach((e=>e.stop())),P.streams.ownPresentation?.getTracks().forEach((e=>e.stop())),P.streams.ownAudio?.getTracks().forEach((e=>e.stop())),P.dataChannel.close(),P.connection.close(),P=void 0)}function U(){if(!P)return;const{emitSignalingData:e,streams:t}=P;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 B(e){if(!P||P.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 L(e){if(!P)return;const{emitSignalingData:t}=P;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:B({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:B({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 $(e){if(P&&P.connection)switch(e["@type"]){case"MediaState":P.mediaState=e,x(),U();break;case"Candidates":{const{pendingCandidates:t,gotInitialSetup:a}=P;e.candidates.forEach((e=>{t.push(e.sdpString)})),a&&await j();break}case"InitialSetup":{const{connection:t,isOutgoing:a}=P;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:B(e.video).payloadTypes?.map(l)||[],videoExtensions:e.video.rtpExtensions};if(await t.setRemoteDescription({sdp:f(n,a,void 0,!0),type:a?"answer":"offer"}),P.conference=n,!a){const e=await t.createAnswer();if(!e)return;await t.setLocalDescription(e),L(g(e,!0))}P.gotInitialSetup=!0,await j();break}}}async function j(){if(!P)return;const{pendingCandidates:e,connection:t}=P;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)))),P.pendingCandidates=[])}async function F(e,t){const a=await e.createOffer(t);L(g(a,!0)),await e.setLocalDescription(a)}var H=a(65054),K=a(60782),Y=a(92387),q=a(33555),J=a(41020),X=a(78958),z=a(44271),W=a(7054),Q=a(42431),ee=a(27225);(0,q.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,X.Ic)(e,{connectionState:"disconnected"},d.participantsCount-1),e={...e,groupCalls:{...e.groupCalls,activeGroupCallId:void 0}},(0,q.R3)(e),await(0,Y.t9)("leaveGroupCall",{call:d,isPageUnload:c}),await(0,Y.t9)("abortRequestGroup","call"),o&&await(0,Y.t9)("discardGroupCall",{call:d}),e=(0,q.Rd)(),s&&(e=(0,X.dc)(e,d.id)),(0,n.Mt)(),(0,q.R3)(e),t.toggleGroupCallPanel({force:void 0,tabId:l}),i||M(),t.afterHangUp(),r&&t.requestMasterAndJoinGroupCall({...r,tabId:l}))})),(0,q.iw)("toggleGroupCallVideo",(async e=>{const t=(0,Q.mU)(e),a=(0,W.dyD)(e,e.currentUserId);a&&t&&(await N("video"),await(0,Y.t9)("editGroupCallParticipant",{call:t,videoStopped:!S("video"),participant:a}))})),(0,q.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,Y.t9)("editGroupCallParticipant",{call:i,raiseHand:n,participant:o})})),(0,q.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,Y.t9)("editGroupCallParticipant",{call:s,volume:Number(i),participant:r}))})),(0,q.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,Y.t9)("editGroupCallParticipant",{call:o,muted:r,participant:s})})),(0,q.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(Z)try{const e=await I("presentation");if(!e)return;return e.getTracks()[0].onended=()=>{Z&&Z.myId&&(delete Z.streams?.[Z.myId].presentation,k(Z.myId),b())},await new Promise((t=>{const{connection:a,dataChannel:n}=O([e],t,!0);Z={...Z,screenshareConnection:a,screenshareDataChannel:n}}))}catch(e){return}}();if(!e)return;await(0,Y.t9)("joinGroupCallPresentation",{call:n,params:e})}else await N("presentation",!1),await(0,Y.t9)("leaveGroupCallPresentation",{call:n});await(0,Y.t9)("editGroupCallParticipant",{call:n,presentationPaused:!S("presentation"),participant:i})}})),(0,q.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(Z)throw Error("Already in call");T("connecting");const i=new MediaStream;return a.srcObject=i,(0,y.Z)(a),Z={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=>{Z={...Z,...O([Z.silence,Z.black],e)}}))}(c,r,s,t.apiUpdate),d=await(0,Y.t9)("joinGroupCall",{call:o,params:l,inviteHash:o.inviteHash});if(e=(0,q.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,q.Rd)();const a=(0,W.Z1J)(e,o.chatId);if(!a)return;await(0,ee.ft)(e,t,a,i)}})),(0,q.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,Y.t9)("getDhConfig");if(!i)return;await(0,Y.t9)("createPhoneCallState",[!0]);const o=await(0,Y.t9)("requestPhoneCall",[i]),s=await(0,Y.t9)("requestCall",{user:n,gAHash:o,isVideo:a.isVideo});s?(e=(0,q.Rd)(),e=(0,J.Sh)(e,(0,K.ee)(s.users,"id")),(0,q.R3)(e)):"hangUp"in t&&t.hangUp({tabId:(0,H._w)()})})),(0,q.iw)("acceptCall",(async e=>{const{phoneCall:t}=e;if(!t)return;const a=await(0,Y.t9)("getDhConfig");if(!a)return;await(0,Y.t9)("createPhoneCallState",[!1]);const n=await(0,Y.t9)("acceptPhoneCall",[a]),i=await(0,Y.t9)("acceptCall",{call:t,gB:n});i&&(e=(0,q.Rd)(),e=(0,J.Sh)(e,(0,K.ee)(i.users,"id")),(0,q.R3)(e))})),(0,q.iw)("sendSignalingData",((e,t,a)=>{const{phoneCall:n}=e;if(!n)return;const i=JSON.stringify(a);(async()=>{const e=await(0,Y.t9)("encodePhoneCallData",[i]);e&&(0,Y.t9)("sendSignalingData",{data:e,call:n})})()})),(0,q.iw)("closeCallRatingModal",((e,t,a)=>{const{tabId:n=(0,H._w)()}=a||{};return(0,z.i)(e,{ratingPhoneCall:void 0},n)})),(0,q.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,Y.t9)("setCallRating",{call:s,rating:n,comment:i}),(0,z.i)(e,{ratingPhoneCall:void 0},o)})),(0,q.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,Y.t9)("destroyPhoneCallState"),D(),e={...e,phoneCall:void 0},(0,q.R3)(e),t.toggleGroupCallPanel({force:void 0,tabId:i}),void t.afterHangUp();if((0,Y.t9)("destroyPhoneCallState"),D(),(0,Y.t9)("discardCall",{call:o,isPageUnload:n}),"requesting"===o.state)return e={...e,phoneCall:void 0},(0,q.R3)(e),t.toggleGroupCallPanel({force:void 0,tabId:i}),void t.afterHangUp();setTimeout((()=>{e=(0,q.Rd)(),e={...e,phoneCall:void 0},(0,q.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,q.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,X.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,X.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(!Z)return;const a=t?Z.screenshareConference:Z.conference,n=t?Z.screenshareConnection:Z.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"]};Z={...Z,...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,q.R3)(e),e=(0,q.Rd)(),n&&n.id&&r.id!==n.id)return void("discarded"!==r.state&&(0,Y.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,z.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,Y.t9)("confirmPhoneCall",[p,ae,ne]),i={...(e=(0,q.Rd)()).phoneCall,emojis:n};e={...e,phoneCall:i},(0,q.R3)(e);const o=await(0,Y.t9)("confirmCall",{call:r,gA:t,keyFingerprint:a});o&&(e=(0,q.Rd)(),e=(0,J.Sh)(e,(0,K.ee)(o.users,"id")),(0,q.R3)(e))})():"active"===d&&u&&"active"!==n?.state&&(c||((0,Y.t9)("receivedCall",{call:r}),(async()=>{const{emojis:t}=await(0,Y.t9)("confirmPhoneCall",[r.gAOrB,ae,ne]),a={...(e=(0,q.Rd)()).phoneCall,emojis:t};e={...e,phoneCall:a},(0,q.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"});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(!P)return;const t=e.streams[0];"audio"===e.track.kind?(P.audio.srcObject=t,P.audio.play().catch(),P.streams.audio=t):"1"===e.transceiver.mid?P.streams.video=t:P.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=>{$(JSON.parse(e.data))};const u=new Audio;P={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,Y.t9)("decodePhoneCallData",[a.data])?.then($);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),ye=a(21273),Ze=a(32340);function Pe(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(47348),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,q.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,q.Sv)(),h=(0,le.Z)(),[C,y,Z]=(0,re.Z)(),P=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)}),[P]);const x=function(e,t,a=[]){return(0,Ne.Z)((e=>{e()}),a,e,t)}(500),_=(0,de.Z)((e=>{e.stopPropagation(),y(),a()})),A=(0,de.Z)((e=>{e.stopPropagation(),v({value:!1}),a()})),D=(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:P,value:i?!I:!b})})),U=(0,de.Z)((e=>{e.stopPropagation(),g(),f({id:P}),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:P,value:!0}):m({participantId:P,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:D},h(i?I?"VoipGroupAllowToSpeak":"VoipMute":b?"VoipGroupUnmuteForMe":"VoipGroupMuteForMe")),!E&&i&&ie.ZP.createElement(Re.Z,{icon:"delete-user",destructive:!0,onClick:_},h("VoipGroupUserRemove")))),!E&&i&&ie.ZP.createElement(Me.Z,{isOpen:C,userId:P,onClose:Z}))}))),_e=(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:"YtzOv_YJhE1p3qIWbAwu",subtitle:"d_IXv97OWeVU1anCLIJV",subtitleText:"hL5wQ6wC2WbM7bmQW7eY",icon:"LK6KFK0AcvforsfYGu1Z",subtitleBlue:"q12ZkFJeUiQJmHmb1R9r",subtitleRed:"xq8TrzM7pkLCcJpb_2Mu",subtitleGreen:"IFhZNdfzczQYrCk5lEEo",avatar:"_B2_m9csWv9ZGwlDIpPc"},De=(0,ie.X$)((0,q.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:y}=(0,be.Z)(a,s),Z=(0,ie.I4)((()=>a.current),[]),P=(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,Z,P,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",Pe(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(_e,{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,Ze.Z)(M))),ie.ZP.createElement(xe,{participant:e,isDropdownOpen:g,positionX:E,positionY:S,transformOriginX:k,transformOriginY:I,style:N,onClose:C,onCloseAnimationEnd:y,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 Be=(0,ie.X$)((0,q.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,q.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(ye.Z,{items:r,onLoadMore:c,style:`transform: translateY(${e}px);`,className:(0,oe.Z)("MaXJ6PbnczgUaXKytU26",!n&&"KDT2Zfq3ho5J3_CUMqK2")},t&&r?.map((e=>t[e]&&ie.ZP.createElement(De,{key:e,teactOrderKey:o.indexOf(e),participant:t[e]}))))})));var Le=a(96264),$e=a(57710),je=a(9933),Fe=a(69118),He=a(62357),Ke=a(74607);const Ye="Yr9Loz5dybqTYl1YGWPC",qe="tZLFA5gL8kShE0_r8Xwb",Je=(0,ie.X$)((0,q.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:y,isRemoved:Z,type:P}=e,{isSelf:b,isMutedByMe:E,isMuted:S}=r,k=t?.id===r.id&&t?.type===P,I=(r.amplitude||0)>d,N=Boolean(r.raiseHandRating),T="video"===P&&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",Pe(r)).replace("%%","%"):u("Speaking")),[b,E,N,S,I,r,u]),V=(0,ie.sO)();Z||(V.current=e);const{x:R,y:G,width:O,height:x}=V.current||{},[_,A,D,U]=Z?[R,G,O,x]:[f,v,h,C],[B,L]=(0,ie.eJ)(!y),$=w(c?.id||l.id),j="video"===P?$?.video:$?.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)((()=>{L(!1)}),[]);const[Y,q]=(0,ie.eJ)(!0),J=(0,de.Z)((()=>{q(!1)}));(0,He.Z)((()=>{if(!H?.active)return;const e=m.current,t=g.current;(0,$e.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,$e.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,Le.Z)(a,0,0,t.width,t.height,2,2),!0)),Fe.T2))})),()=>{n=!1}}),[H]);const X=(0,ie.sO)(null),z=(0,ie.sO)(null),{isContextMenuOpen:W,contextMenuPosition:Q,handleContextMenu:ee,handleContextMenuClose:te,handleContextMenuHide:ae}=(0,be.Z)(X,b),ne=(0,ie.I4)((()=>X.current),[]),se=(0,ie.I4)((()=>X.current.closest(".custom-scroll, .no-scrollbar")),[]),re=(0,ie.I4)((()=>z.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:P})}),[l,k,a,P,c?.id]);return ie.ZP.createElement("div",{className:(0,oe.Z)("VowYvAYnpOoRyvJApJQx",(B||Z)&&"rhyIpeB0s5L9Rmgi17tE",y&&"YdJNWDXWUzCFMWFDHCB1",s,k&&"OyzsHbgzvjeEUTE090PB"),style:`--x: ${_}px; --y: ${A}px; --width: ${D}px; --height: ${U}px;`,ref:X,onContextMenu:ee,onDoubleClick:n?he:void 0},ie.ZP.createElement("div",{className:(0,oe.Z)("T3WHHUMTxj1TjHVdEQEg",I&&"yB5xApXNfpH_uWMlaJ_v")},Y&&ie.ZP.createElement(Ke.Z,{className:(0,oe.Z)(Ye,"hjZk9WRq4TrqMCq3E2y8")}),H&&ie.ZP.createElement("video",{className:(0,oe.Z)(Ye,T&&qe),muted:!0,autoPlay:!0,playsInline:!0,srcObject:H,ref:m,onCanPlay:J}),ie.ZP.createElement("canvas",{className:(0,oe.Z)("TTT3HkSjEHudE0V0mbIS Yr9Loz5dybqTYl1YGWPC",T&&qe),ref:g}),ie.ZP.createElement("div",{className:"JGuT5GiXuGEeFNyc_SyE"},ie.ZP.createElement("canvas",{className:(0,oe.Z)("aGXmhcH9sptqhStorby8",T&&qe),ref:p})),n&&ie.ZP.createElement(ge.Z,{round:!0,size:"smaller",ripple:!0,color:"translucent",className:"loYfROdAEWBH4mFbwlew",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:"TipRbLLEOnRQN7eDzIlX"},ie.ZP.createElement("div",{className:"TRFmGn5RJRcHhQSXUkg8"},ie.ZP.createElement(Se.Z,{peer:c||l,className:"xjevYlbKT3orz6OwaJTN"}),ie.ZP.createElement("div",{className:"VNKqmM8nVTBnQLg84tVQ"},M)),ie.ZP.createElement(_e,{participant:r,className:"FhEGCqYjf67Tz1J54Nf7",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:z}))}))),Xe=()=>{navigator.vibrate?.(50)};var ze=a(49204);const We=(0,ie.X$)((0,q.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,q.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)((()=>{Xe(),o()}),[o]),C=(0,ie.I4)((()=>{if(m){if(d)return;return Xe(),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]),y=(0,ie.I4)((()=>{m||(h(),l.current="up")}),[m,h]);return ie.ZP.createElement(ge.Z,{round:!0,size:"default",className:(0,oe.Z)("cYoMo7_F9FClYElCiCPz",!p&&t&&"qogJ3qpYtfXe51F2oHQC",!p&&m&&"_BwpttCUQ7dx5QS3FZr8",e),onMouseDown:C,onMouseUp:y,ariaLabel:c(n?"VoipUnmute":"VoipMute"),disabled:p},ie.ZP.createElement(Te.Z,{tgsUrl:Ie.l[v],size:36,play:f.toString(),playSegment:f,className:"Xb5vLmvwjtecjpIdukD8",forceAlways:!0}),ie.ZP.createElement(ze.Z,{className:(0,oe.Z)("NzuTkuoPRWdJQIgGM6HC",p&&"cLDJwFMhqkiwNmn9Xkx0"),color:"white"}))}))),Qe={root:"fyUCcatntsTa_YkVpZCR",panelWrapper:"b3jsxTWWaVRz5PgjlLVf",panel:"XzyFw6Jv2_ezVQGIqawU",panelScrollTrigger:"V7wA8W8hNoCcBKHxf4hT",panelHeader:"t6Om0WIUsRLLZV9Cc0KJ",scrolled:"kGj_uhd6vwlqYp7AYUcx",fullscreen:"GnCdvyLEoJLuYpmgt4Ss",landscape:"gR_aXfrHQVIxdqlD7Kzc",headerButton:"obtrrwNt6GBLqhM9oFmm",firstButton:"zpgyOLRxhZgDHkFynsU0",lastButton:"o0dIwExEv0BpVIQOsDnM",panelHeaderText:"UMJnOojFmrqTKlWMo8aG",title:"AcV4YuEJQsio2Y1mb8NI",bigger:"KzSCbnCRFSRjnjNvs7DO",subtitle:"w7hs8dy7SXtq4hoRdA7v",participants:"HzQTDfEVKQFHpKBBL2Xk",participantVideos:"ediyUOQamD3wqwyt1OHn",addParticipantButton:"LrlxHbsK4nR40UwUT9tK",videos:"V06H2v7o5yKYh54ZUkAW",mainVideoContainer:"xYluQGqciLtWwKbroLFE",videosHeader:"ILuaK6cG99MeCGr9DNiI",appFullscreen:"aUXjtany4EYpGNMLdcke",videosHeaderLastButton:"FRWFfGWGqAfcIaiYI43I",videosContent:"hZ3hHp1KVhCV8WLZTQzu",actions:"IlgtQK0Z99LuWgmiCmpc",actionButton:"iX69gJg2DcXiCjcn7Z9_",destructive:"BDXZ55Nvs0ov0_K2MCvR",canRequestToSpeak:"uvqh2N80Lk6ZMNN3rc1A",muted:"tuWi4pcqOQX8sfdvlCaN",portrait:"WnKR5AT56cbE5LSxbJoa",noVideoParticipants:"JO8y1VdvKW0gKzSQXQh0",noSidebar:"yiyRELlSa8Nyrn_onUsb"},et=(0,ie.X$)((0,q.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,q.Sv)(),h=(0,le.Z)(),C=(0,ie.sO)(null),y=(0,ie.sO)(null),Z=(0,ie.sO)(null),P=(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)(P,S?k:void 0),{isMobile:N,isLandscape:T}=(0,se.ZP)(),[M,V,R]=(0,re.Z)(),[G,O,x]=(0,re.Z)(!0),_=Boolean(M&&T),A=(0,ue.Ar)(),D=(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]),B=U.length>0,L=i||h("VoipGroupVoiceChat"),$=h("Participants",n,"i"),[j,F,H]=(0,re.Z)(),[Y,J]=(0,ie.eJ)(!1),[X,z]=(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(),J(!1)})),ye=(0,de.Z)((()=>{C.current&&!N&&(M?R():V())})),Ze=(0,de.Z)((()=>{G?x():O()})),Pe=(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:X})})),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,y=C%2==1,Z=2,P=Math.ceil(C/Z),b=(f-10*(Z-1))/Z,w=Math.max(0,y?240+(P-1)*b+8*(P-1):P*b+8*(P-1));for(let t=0;t<C;t++){const a=y&&0===t,n=a?f:b,i=a?240:b,o=y&&0!==t?t+1:t,s=(e?0:m)+o%Z*(n+10),r=(e?0:g)+(y&&0!==t?248+(Math.floor(o/Z)-1)*(i+8):Math.floor(o/Z)*(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:y,height:Z}=o.getBoundingClientRect(),P=function(e){return e>=25?5:e>=13?4:e>=7?3:e>=3?2:1}(l),b=Math.ceil(l/P),w=b*P>l,E=(y-10*(P-1))/P,S=(Z-8*(b-1))/b,k=E*(l%P);for(let e=0;e<l;e++){const t=Math.floor(e/P),n=h+e%P*(E+10)+(w&&t===b-1?(y-k)/2:0),i=C+Math.floor(e/P)*(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:y,secondaryContainerRef:Z,videoParticipants:U,isLandscapeLayout:_,pinnedVideo:Te}),Ge=(0,de.Z)((e=>{Me(e),e&&!M&&V()})),Oe=(0,de.Z)((()=>{D&&Me({id:D.id,type:"screen"})}));return(0,ie.d4)(Oe,[Oe,Boolean(D)]),(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,_&&Qe.landscape,!B&&Qe.noVideoParticipants,!_&&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:ye,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:Ze,ariaLabel:h("AccDescrExpandPanel")},ie.ZP.createElement("i",{className:"icon icon-sidebar","aria-hidden":!0}))),ie.ZP.createElement("div",{className:Qe.videosContent,ref:y})),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:P}),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:ye,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:Pe,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:Ze,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),!Ne&&ie.ZP.createElement("span",{className:Qe.subtitle},$)),!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:Z,style:`height: ${Re}px;`},Ve.map((e=>{const t=r[e.participantId];return e.isRemounted&&t?ie.ZP.createElement(Je,{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(Be,{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(Je,{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(Y?"VoipGroupEndAlertTitle":"VoipGroupLeaveAlertTitle")},ie.ZP.createElement("p",null,h(Y?"VoipGroupEndAlertText":"VoipGroupLeaveAlertText")),!Y&&ie.ZP.createElement(fe.Z,{label:h("VoipGroupEndChat"),checked:X,onCheck:z}),ie.ZP.createElement("div",{className:"dialog-buttons"},ie.ZP.createElement(ge.Z,{isText:!0,className:"confirm-dialog-button",onClick:Ee},h(Y?"VoipGroupEnd":"VoipGroupLeave")),ie.ZP.createElement(ge.Z,{isText:!0,className:"confirm-dialog-button",onClick:Ce},h("Cancel")))))}))),tt=(0,ie.X$)((0,q.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,q.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(790),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:"eWbOLx__FZXR1sqKEJek"},ie.ZP.createElement(ge.Z,{round:!0,className:(0,oe.Z)(o,"XKOJvKiD4DsRfJLLhnw2",r&&"qvAVe7qcyaEvRQQ1StFI"),onClick:e,disabled:s},a||ie.ZP.createElement("i",{className:(0,oe.Z)(i,"icon",`icon-${n}`)})),ie.ZP.createElement("div",{className:"wnAniFJmQ7ocVtjRHNey"},t)))),ot={root:"AddQYAOZJv2f7U7qIfC3",blurred:"anFtHj7Wvsv4M_2I2EFF","single-column":"Oi7aFYBAbl4bYichdt52",singleColumn:"Oi7aFYBAbl4bYichdt52",header:"_iK8HccGNSmmo2wL7tMs","close-button":"U66J7V5JKTCiktgwYpcC",closeButton:"U66J7V5JKTCiktgwYpcC","emojis-backdrop":"IekzemHkkO4bfrWHmxlv",emojisBackdrop:"IekzemHkkO4bfrWHmxlv",open:"hiNHKiq2owo1FvdT9a5g",emojis:"BjOb1fDymE5GCiJ4g6YN","emoji-tooltip":"Ci9ie86NFinrXvowDx23",emojiTooltip:"Ci9ie86NFinrXvowDx23","user-info":"eiM2IbZjKKAwrfNtXtAy",userInfo:"eiM2IbZjKKAwrfNtXtAy",buttons:"AtK8DjRToL8Uk7ZAY25p",leave:"uI2mkCTKDcqYPu64xKOk",accept:"PC2FeM0OEDDW0TVFGMkk","accept-icon":"hBxp1Loj3vj4DtnculDA",acceptIcon:"hBxp1Loj3vj4DtnculDA","main-video":"lXMZESnc4CBKQbvV7qkL",mainVideo:"lXMZESnc4CBKQbvV7qkL","second-video":"cnQvI_xwAbO0EEwRcLsg",secondVideo:"cnQvI_xwAbO0EEwRcLsg",visible:"XaD79h6hSiEi0ypkn5OK",fullscreen:"NlF9_Kb2le_3B712PZnO"},st=(0,ie.X$)((0,q.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,q.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 y=(0,ie.I4)((()=>{l(),m&&f()}),[f,m,l]),Z="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"}):Z?c({sound:"end"}):E?c({sound:"ringing"}):k&&c({sound:"connect"})}),[b,Z,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,D=P?.streams,U=D?.ownAudio?.getTracks()[0].enabled,B=D?.ownPresentation?.getTracks()[0].enabled,L=D?.ownVideo?.getTracks()[0].enabled,[$,j,F]=(0,re.Z)(),[H,K,Y]=(0,re.Z)(),J=(0,ie.I4)((()=>{B&&j(),L&&K(),setTimeout((async()=>{await A("presentation"),F(),Y()}),250)}),[B,L,j,K,F,Y]),X=(0,ie.I4)((()=>{L&&K(),B&&j(),setTimeout((async()=>{await A("video"),F(),Y()}),250)}),[B,L,j,K,F,Y]),z=(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(!P||!P.facingMode)return;const e=P.streams.ownVideo;if(!e)return;const t=e.getTracks()[0];if(!t)return;const a=P.connection.getSenders().find((e=>t.id===e.track?.id));if(a){P.facingMode="environment"===P.facingMode?"user":"environment";try{const e=await _("video",P.facingMode);await a.replaceTrack(e.getTracks()[0]),P.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:y,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&&D?.presentation&&ie.ZP.createElement("video",{className:ot.mainVideo,muted:!0,autoPlay:!0,playsInline:!0,srcObject:D.presentation}),"active"===a?.videoState&&D?.video&&ie.ZP.createElement("video",{className:ot.mainVideo,muted:!0,autoPlay:!0,playsInline:!0,srcObject:D.video}),ie.ZP.createElement("video",{className:(0,oe.Z)(ot.secondVideo,!$&&B&&ot.visible,m&&ot.fullscreen),muted:!0,autoPlay:!0,playsInline:!0,srcObject:D?.ownPresentation}),ie.ZP.createElement("video",{className:(0,oe.Z)(ot.secondVideo,!H&&L&&ot.visible,m&&ot.fullscreen),muted:!0,autoPlay:!0,playsInline:!0,srcObject:D?.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:y,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,Ze.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:z,icon:"microphone",isDisabled:!S,isActive:U,label:o(U?"lng_call_mute_audio":"lng_call_unmute_audio")}),ie.ZP.createElement(it,{onClick:X,icon:"video",isDisabled:!S,isActive:L,label:o(L?"lng_call_stop_video":"lng_call_start_video")}),L&&(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:J,icon:"share-screen",isDisabled:!S,isActive:B,label:o("lng_call_screencast")}),w&&ie.ZP.createElement(it,{onClick:r,icon:"phone-discard",isDisabled:Z,label:o("lng_call_accept"),className:ot.accept,iconClassName:ot.acceptIcon}),ie.ZP.createElement(it,{onClick:M,icon:"phone-discard",isDisabled:Z,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,q.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:"wLqZtZzJMOmPkr1Z7kT5"},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&&"o_nOyYqj5URif5S86StK","OLQPS_OeztNYIaL15tdz"),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)("ZToDNX6q1Yhf4aDPyuJF",4!==o&&void 0!==o&&"HdCq8jVctaJoit7bdgZd")}),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.f812ca56e8d765d22a04.js.map