import { defineComponent, computed, watch, openBlock, createBlock, unref, isRef, withCtx, createElementBlock, Fragment, renderList } from "vue";
import { useI18n } from "../../locales/index.mjs";
import Select from "./base/Select/index.mjs";
import OPtion from "./base/Option/index.mjs";
import TUIRoomEngine__default, { TUIVideoQuality } from "@tencentcloud/tuiroom-engine-js";
import { useRoomStore } from "../../stores/room.mjs";
import useGetRoomEngine from "../../hooks/useRoomEngine.mjs";
import { storeToRefs } from "pinia";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "VideoProfile",
  setup(__props) {
    const roomEngine = useGetRoomEngine();
    const roomStore = useRoomStore();
    const { localVideoQuality } = storeToRefs(roomStore);
    const { t } = useI18n();
    const videoProfileList = computed(() => [
      { label: t("Low Definition"), value: TUIVideoQuality.kVideoQuality_360p },
      {
        label: t("Standard Definition"),
        value: TUIVideoQuality.kVideoQuality_540p
      },
      { label: t("High Definition"), value: TUIVideoQuality.kVideoQuality_720p },
      { label: t("Super Definition"), value: TUIVideoQuality.kVideoQuality_1080p }
    ]);
    watch(localVideoQuality, (val) => {
      var _a;
      (_a = roomEngine.instance) == null ? void 0 : _a.updateVideoQuality({ quality: val });
    });
    TUIRoomEngine__default.once("ready", () => {
      var _a;
      (_a = roomEngine.instance) == null ? void 0 : _a.updateVideoQuality({ quality: localVideoQuality.value });
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(Select), {
        modelValue: unref(localVideoQuality),
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(localVideoQuality) ? localVideoQuality.value = $event : null),
        placeholder: "placeholder",
        class: "select",
        teleported: false,
        "popper-append-to-body": false
      }, {
        default: withCtx(() => [
          (openBlock(true), createElementBlock(Fragment, null, renderList(videoProfileList.value, (item, index) => {
            return openBlock(), createBlock(unref(OPtion), {
              key: index,
              label: item.label,
              value: item.value
            }, null, 8, ["label", "value"]);
          }), 128))
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
});
export {
  _sfc_main as default
};
