"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.RoomView = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _livekitClient = require("livekit-client");
var _reactNative2 = require("@livekit/react-native");
var _styles = require("./styles");
const RoomView = ({
  onLocalParticipantReady,
  isFrontCamera
}) => {
  const {
    localParticipant
  } = (0, _reactNative2.useLocalParticipant)();
  const styles = (0, _styles.useStyles)();
  (0, _react.useEffect)(() => {
    if (localParticipant && onLocalParticipantReady) {
      onLocalParticipantReady(localParticipant);
    }
  }, [localParticipant, onLocalParticipantReady]);
  if (!(localParticipant !== null && localParticipant !== void 0 && localParticipant.isCameraEnabled)) {
    return /*#__PURE__*/React.createElement(_reactNative.View, {
      style: styles.roomContainer
    });
  }
  const cameraTrack = localParticipant.getTrackPublication(_livekitClient.Track.Source.Camera);
  if (!(cameraTrack !== null && cameraTrack !== void 0 && cameraTrack.track)) {
    return /*#__PURE__*/React.createElement(_reactNative.View, {
      style: styles.roomContainer
    });
  }
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.roomContainer
  }, /*#__PURE__*/React.createElement(_reactNative2.VideoTrack, {
    trackRef: {
      participant: localParticipant,
      publication: cameraTrack,
      source: _livekitClient.Track.Source.Camera
    },
    style: styles.videoTrack,
    mirror: isFrontCamera
  }));
};
exports.RoomView = RoomView;
//# sourceMappingURL=RoomView.js.map