import { t } from '../../i18n/index.js'; // Encrypted voice / video call UI for SecureBit.chat. // // Faithful implementation of the "SecureBit Chat.dc.html" design: the voice-call // (expanded), video-call (expanded) and minimized-widget states use the exact // icons, sizes, colours and layout from that mockup. This component is a thin // presentational shell over the call subsystem in EnhancedSecureWebRTCManager — // all media and crypto live there. Media is DTLS-SRTP encrypted on the same // SAS-verified transport as the chat (see the manager's call section). // // Loaded as a native ES module (no JSX compilation), so this file uses // React.createElement directly, mirroring the other components/ui modules. const CallUIComponent = ({ webrtcManager, peerTitle }) => { const h = React.createElement; const MONO = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace"; // Exact SVG icons lifted from the design. Rendered via innerHTML (CSP-safe — // markup, not script); `stroke="currentColor"` inherits the button's colour. const ICON = { lock: '', minimize: '', expand: '', user: '', micOn: '', micOff: '', camOn: '', camOff: '', flip: '', phone: '', phoneHangup: '' }; const svg = (inner, size, sw) => h('span', { style: { display: 'grid', placeItems: 'center', width: size + 'px', height: size + 'px' }, dangerouslySetInnerHTML: { __html: `${inner}` } }); const [call, setCall] = React.useState(() => (webrtcManager?.getCallState?.() || { phase: 'idle', active: false })); const [minimized, setMinimized] = React.useState(false); const [seconds, setSeconds] = React.useState(0); const remoteVideoRef = React.useRef(null); const remoteAudioRef = React.useRef(null); const selfVideoRef = React.useRef(null); // Subscribe to call-state changes from the active session's manager. React.useEffect(() => { if (!webrtcManager) return; const onState = (state) => setCall(state); const prev = webrtcManager.onCallStateChanged; webrtcManager.onCallStateChanged = onState; setCall(webrtcManager.getCallState ? webrtcManager.getCallState() : { phase: 'idle', active: false }); return () => { if (webrtcManager.onCallStateChanged === onState) webrtcManager.onCallStateChanged = prev || null; }; }, [webrtcManager]); const phase = call.phase || 'idle'; const active = !!call.active; const isVideo = !!call.withVideo || !!call.remoteHasVideo; // Attach media streams to the