import { UserTrackContext } from '../../services/UserTrackProvider';
import { Button, Icon } from '../../themes/components';
import React, { useContext } from 'react';
import { useSelector } from 'react-redux';
const CameraSwitcher = () => {
    const videoTrackSelection = useSelector((state) => state.participant.videoTrackSelection);
    const videoProduction = useSelector((state) => state.participant.videoProduction);
    const { mediaTracks: { webcamTrack, }, inputDevices: { onVideoInputChange, videoInputDevices, }, videoButtonsEnabled, } = useContext(UserTrackContext);
    const switchCamera = () => {
        // check if camera is disbabled
        if (videoButtonsEnabled) {
            videoInputDevices.forEach((d) => {
                if (d.deviceId !== videoTrackSelection?.selectedDeviceId) {
                    onVideoInputChange(d.deviceId);
                }
            });
        }
    };
    return (<Button onClick={switchCamera}><Icon name="flip-camera-ios" color={`${videoButtonsEnabled ? 'textPrimary.200' : 'textPrimary.400'}`} disabled={!videoButtonsEnabled} boxSize={24}/></Button>);
};
export default CameraSwitcher;
//# sourceMappingURL=CameraSwitcher.js.map