import { useEffect } from 'react';
import { View } from 'react-native';
import { Track } from 'livekit-client';
import { VideoTrack, useLocalParticipant } from '@livekit/react-native';
import { useStyles } from './styles';
export const RoomView = ({
  onLocalParticipantReady,
  isFrontCamera
}) => {
  const {
    localParticipant
  } = useLocalParticipant();
  const styles = useStyles();
  useEffect(() => {
    if (localParticipant && onLocalParticipantReady) {
      onLocalParticipantReady(localParticipant);
    }
  }, [localParticipant, onLocalParticipantReady]);
  if (!(localParticipant !== null && localParticipant !== void 0 && localParticipant.isCameraEnabled)) {
    return /*#__PURE__*/React.createElement(View, {
      style: styles.roomContainer
    });
  }
  const cameraTrack = localParticipant.getTrackPublication(Track.Source.Camera);
  if (!(cameraTrack !== null && cameraTrack !== void 0 && cameraTrack.track)) {
    return /*#__PURE__*/React.createElement(View, {
      style: styles.roomContainer
    });
  }
  return /*#__PURE__*/React.createElement(View, {
    style: styles.roomContainer
  }, /*#__PURE__*/React.createElement(VideoTrack, {
    trackRef: {
      participant: localParticipant,
      publication: cameraTrack,
      source: Track.Source.Camera
    },
    style: styles.videoTrack,
    mirror: isFrontCamera
  }));
};
//# sourceMappingURL=RoomView.js.map