import { defineComponent, watch, createBlock, openBlock, unref, withCtx, createCommentVNode } from "vue";
import { useRoomState, useRoomParticipantState, RoomType, RoomLayoutTemplate, RoomView } from "tuikit-atomicx-vue3/room";
import _sfc_main$1 from "./StandardParticipantViewUI/index.vue.mjs";
import WebinarParticipantViewUI from "./WebinarParticipantViewUI/index.vue2.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    layoutTemplate: {}
  },
  emits: ["update:layoutTemplate"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const { currentRoom } = useRoomState();
    const { participantList, participantWithScreen } = useRoomParticipantState();
    watch(participantWithScreen, (newVal, oldVal) => {
      var _a;
      if (((_a = currentRoom.value) == null ? void 0 : _a.roomType) === RoomType.Standard && newVal && !oldVal) {
        emits("update:layoutTemplate", RoomLayoutTemplate.SidebarLayout);
      }
    });
    watch(
      () => participantList.value.length + (participantWithScreen.value ? 1 : 0),
      (val) => {
        var _a;
        if (((_a = currentRoom.value) == null ? void 0 : _a.roomType) === RoomType.Standard && 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 }) => {
          var _a, _b;
          return [
            ((_a = unref(currentRoom)) == null ? void 0 : _a.roomType) === unref(RoomType).Standard ? (openBlock(), createBlock(_sfc_main$1, {
              key: 0,
              participant,
              "stream-type": streamType
            }, null, 8, ["participant", "stream-type"])) : createCommentVNode("", true),
            ((_b = unref(currentRoom)) == null ? void 0 : _b.roomType) === unref(RoomType).Webinar ? (openBlock(), createBlock(WebinarParticipantViewUI, {
              key: 1,
              participant,
              "stream-type": streamType
            }, null, 8, ["participant", "stream-type"])) : createCommentVNode("", true)
          ];
        }),
        _: 1
      }, 8, ["layout-template"]);
    };
  }
});
export {
  _sfc_main as default
};
