import { defineComponent, ref, createElementBlock, openBlock, Fragment, createBlock, createCommentVNode } from "vue";
import CreateRoomView from "./CreateRoomView.vue.mjs";
import JoinRoomView from "./JoinRoomView.vue.mjs";
import PreviewView from "./PreviewView.vue.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  emits: ["logout", "create-room", "join-room", "camera-preference-change", "microphone-preference-change"],
  setup(__props, { emit: __emit }) {
    const emit = __emit;
    const cameraPreference = ref(true);
    const microphonePreference = ref(true);
    const createRoomViewVisible = ref(false);
    const joinRoomViewVisible = ref(false);
    function handleLogout() {
      emit("logout");
    }
    const handleCreateRoom = (roomId) => {
      emit("create-room", roomId);
    };
    const handleJoinRoom = (roomId) => {
      emit("join-room", roomId);
    };
    const handleCameraPreferenceChange = (isOpen) => {
      cameraPreference.value = isOpen;
      emit("camera-preference-change", isOpen);
    };
    const handleMicrophonePreferenceChange = (isOpen) => {
      microphonePreference.value = isOpen;
      emit("microphone-preference-change", isOpen);
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock(Fragment, null, [
        !createRoomViewVisible.value && !joinRoomViewVisible.value ? (openBlock(), createBlock(PreviewView, {
          key: 0,
          onLogout: handleLogout,
          onCreateRoom: _cache[0] || (_cache[0] = ($event) => createRoomViewVisible.value = true),
          onJoinRoom: _cache[1] || (_cache[1] = ($event) => joinRoomViewVisible.value = true),
          onCameraPreferenceChange: handleCameraPreferenceChange,
          onMicrophonePreferenceChange: handleMicrophonePreferenceChange
        })) : createCommentVNode("", true),
        createRoomViewVisible.value ? (openBlock(), createBlock(CreateRoomView, {
          key: 1,
          "camera-preference": cameraPreference.value,
          "microphone-preference": microphonePreference.value,
          onCreateRoom: handleCreateRoom,
          onBack: _cache[2] || (_cache[2] = () => createRoomViewVisible.value = false),
          onCameraPreferenceChange: handleCameraPreferenceChange,
          onMicrophonePreferenceChange: handleMicrophonePreferenceChange
        }, null, 8, ["camera-preference", "microphone-preference"])) : createCommentVNode("", true),
        joinRoomViewVisible.value ? (openBlock(), createBlock(JoinRoomView, {
          key: 2,
          "camera-preference": cameraPreference.value,
          "microphone-preference": microphonePreference.value,
          onJoinRoom: handleJoinRoom,
          onBack: _cache[3] || (_cache[3] = () => joinRoomViewVisible.value = false),
          onCameraPreferenceChange: handleCameraPreferenceChange,
          onMicrophonePreferenceChange: handleMicrophonePreferenceChange
        }, null, 8, ["camera-preference", "microphone-preference"])) : createCommentVNode("", true)
      ], 64);
    };
  }
});
export {
  _sfc_main as default
};
