import { defineComponent, watch, createBlock, openBlock, unref, withCtx, createVNode } from "vue";
import { useRoomParticipantState, RoomLayoutTemplate, RoomView } from "tuikit-atomicx-vue3/room";
import _sfc_main$1 from "./ParticipantViewUI/index.vue.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    layoutTemplate: {}
  },
  emits: ["update:layoutTemplate"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const { participantList, participantWithScreen } = useRoomParticipantState();
    watch(participantWithScreen, (newVal, oldVal) => {
      if (newVal && !oldVal) {
        emits("update:layoutTemplate", RoomLayoutTemplate.SidebarLayout);
      }
    });
    watch(
      () => participantList.value.length + (participantWithScreen.value ? 1 : 0),
      (val) => {
        if (val === 1 && props.layoutTemplate !== RoomLayoutTemplate.GridLayout) {
          emits("update:layoutTemplate", RoomLayoutTemplate.GridLayout);
        }
      }
    );
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(RoomView), { "layout-template": __props.layoutTemplate }, {
        participantViewUI: withCtx(({ participant, streamType }) => [
          createVNode(_sfc_main$1, {
            participant,
            "stream-type": streamType
          }, null, 8, ["participant", "stream-type"])
        ]),
        _: 1
      }, 8, ["layout-template"]);
    };
  }
});
export {
  _sfc_main as default
};
