"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const uikitBaseComponentVue3 = require("@tencentcloud/uikit-base-component-vue3");
const room = require("tuikit-atomicx-vue3/room");
const PopUpArrowDown = require("../base/PopUpArrowDown.vue2.js");
const CurrentRoomInfo = require("./CurrentRoomInfo.vue2.js");
const _hoisted_1 = { class: "room-title" };
const _hoisted_2 = { class: "room-title-top" };
const _hoisted_3 = { class: "room-title-name" };
const _hoisted_4 = { class: "room-duration" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "index",
  setup(__props) {
    const { currentRoom } = room.useRoomState();
    const isPopupVisible = vue.ref(false);
    const currentTime = vue.ref(Date.now());
    let timer = null;
    vue.onMounted(() => {
      timer = setInterval(() => {
        currentTime.value = Date.now();
      }, 1e3);
    });
    vue.onUnmounted(() => {
      if (timer) {
        clearInterval(timer);
      }
    });
    const durationTime = vue.computed(() => {
      var _a;
      if (!((_a = currentRoom.value) == null ? void 0 : _a.roomId)) {
        return "00:00";
      }
      const duration = currentTime.value - (currentRoom.value.createTime ?? 0);
      const totalSeconds = Math.floor(duration / 1e3);
      const hours = Math.floor(totalSeconds / 3600);
      const minutes = Math.floor(totalSeconds % 3600 / 60);
      const seconds = totalSeconds % 60;
      if (hours > 0) {
        return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
      }
      return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
    });
    return (_ctx, _cache) => {
      var _a, _b, _c;
      return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
        ((_a = vue.unref(currentRoom)) == null ? void 0 : _a.roomId) ? (vue.openBlock(), vue.createElementBlock("div", {
          key: 0,
          class: "room-header",
          onClick: _cache[0] || (_cache[0] = ($event) => isPopupVisible.value = true)
        }, [
          vue.createElementVNode("div", _hoisted_1, [
            vue.createElementVNode("div", _hoisted_2, [
              vue.createElementVNode("span", _hoisted_3, vue.toDisplayString(((_b = vue.unref(currentRoom)) == null ? void 0 : _b.roomName) || ((_c = vue.unref(currentRoom)) == null ? void 0 : _c.roomId)), 1),
              vue.createVNode(vue.unref(uikitBaseComponentVue3.IconCaretDownSmall), {
                size: 24,
                class: "room-title-icon"
              })
            ]),
            vue.createElementVNode("span", _hoisted_4, vue.toDisplayString(durationTime.value), 1)
          ])
        ])) : vue.createCommentVNode("", true),
        vue.createVNode(vue.unref(uikitBaseComponentVue3.TUIPopup), {
          visible: isPopupVisible.value,
          "onUpdate:visible": _cache[2] || (_cache[2] = ($event) => isPopupVisible.value = $event)
        }, {
          default: vue.withCtx(() => [
            vue.createVNode(PopUpArrowDown.default, {
              onClick: _cache[1] || (_cache[1] = ($event) => isPopupVisible.value = false)
            }),
            vue.createVNode(CurrentRoomInfo.default)
          ]),
          _: 1
        }, 8, ["visible"])
      ], 64);
    };
  }
});
exports.default = _sfc_main;
