"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const CreateRoomView = require("./CreateRoomView.vue.js");
const JoinRoomView = require("./JoinRoomView.vue.js");
const PreviewView = require("./PreviewView.vue.js");
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "index",
  emits: ["logout", "create-room", "join-room", "camera-preference-change", "microphone-preference-change"],
  setup(__props, { emit: __emit }) {
    const emit = __emit;
    const cameraPreference = vue.ref(true);
    const microphonePreference = vue.ref(true);
    const createRoomViewVisible = vue.ref(false);
    const joinRoomViewVisible = vue.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 vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
        !createRoomViewVisible.value && !joinRoomViewVisible.value ? (vue.openBlock(), vue.createBlock(PreviewView.default, {
          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
        })) : vue.createCommentVNode("", true),
        createRoomViewVisible.value ? (vue.openBlock(), vue.createBlock(CreateRoomView.default, {
          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"])) : vue.createCommentVNode("", true),
        joinRoomViewVisible.value ? (vue.openBlock(), vue.createBlock(JoinRoomView.default, {
          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"])) : vue.createCommentVNode("", true)
      ], 64);
    };
  }
});
exports.default = _sfc_main;
