"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 useCopy = require("../../hooks/useCopy.js");
const utils = require("../../utils/utils.js");
const _hoisted_1 = {
  key: 0,
  class: "room-header"
};
const _hoisted_2 = { class: "room-title" };
const _hoisted_3 = { class: "room-title-name" };
const _hoisted_4 = { class: "room-duration" };
const _hoisted_5 = { class: "room-info" };
const _hoisted_6 = { class: "room-info-item" };
const _hoisted_7 = { class: "room-info-label" };
const _hoisted_8 = { class: "room-info-value" };
const _hoisted_9 = { class: "room-info-item" };
const _hoisted_10 = { class: "room-info-label" };
const _hoisted_11 = { class: "room-info-value" };
const _hoisted_12 = {
  key: 0,
  class: "room-info-item"
};
const _hoisted_13 = { class: "room-info-label" };
const _hoisted_14 = { class: "room-info-value" };
const _hoisted_15 = { class: "room-info-item" };
const _hoisted_16 = { class: "room-info-label" };
const _hoisted_17 = { class: "room-info-value" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "index",
  setup(__props) {
    const { t } = uikitBaseComponentVue3.useUIKit();
    const { currentRoom } = room.useRoomState();
    const { copy } = useCopy.useCopy();
    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 roomLink = vue.computed(() => {
      var _a;
      if (!((_a = currentRoom.value) == null ? void 0 : _a.roomId)) {
        return "";
      }
      return utils.generateRoomLink(currentRoom.value.roomId, currentRoom.value.password, currentRoom.value.roomType);
    });
    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;
      return ((_a = vue.unref(currentRoom)) == null ? void 0 : _a.roomId) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.createVNode(vue.unref(uikitBaseComponentVue3.TUIDropdown), {
          trigger: "click",
          placement: "bottom",
          hideOnClick: false,
          teleported: false
        }, {
          dropdown: vue.withCtx(() => {
            var _a2, _b, _c, _d, _e;
            return [
              vue.createElementVNode("div", _hoisted_5, [
                vue.createElementVNode("div", _hoisted_6, [
                  vue.createElementVNode("div", _hoisted_7, vue.toDisplayString(vue.unref(t)("CurrentRoomInfo.Host")), 1),
                  vue.createElementVNode("div", _hoisted_8, vue.toDisplayString(((_a2 = vue.unref(currentRoom)) == null ? void 0 : _a2.roomOwner.userName) || ((_b = vue.unref(currentRoom)) == null ? void 0 : _b.roomOwner.userId)), 1)
                ]),
                vue.createElementVNode("div", _hoisted_9, [
                  vue.createElementVNode("div", _hoisted_10, vue.toDisplayString(vue.unref(t)("CurrentRoomInfo.RoomId")), 1),
                  vue.createElementVNode("div", _hoisted_11, vue.toDisplayString((_c = vue.unref(currentRoom)) == null ? void 0 : _c.roomId), 1),
                  vue.createElementVNode("div", {
                    class: "room-info-copy",
                    onClick: _cache[0] || (_cache[0] = () => {
                      var _a3;
                      return vue.unref(copy)(((_a3 = vue.unref(currentRoom)) == null ? void 0 : _a3.roomId) || "");
                    })
                  }, [
                    vue.createVNode(vue.unref(uikitBaseComponentVue3.IconCopy), { class: "copy-icon" }),
                    vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(t)("CurrentRoomInfo.Copy")), 1)
                  ])
                ]),
                ((_d = vue.unref(currentRoom)) == null ? void 0 : _d.password) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_12, [
                  vue.createElementVNode("div", _hoisted_13, vue.toDisplayString(vue.unref(t)("CurrentRoomInfo.Password")), 1),
                  vue.createElementVNode("div", _hoisted_14, vue.toDisplayString((_e = vue.unref(currentRoom)) == null ? void 0 : _e.password), 1),
                  vue.createElementVNode("div", {
                    class: "room-info-copy",
                    onClick: _cache[1] || (_cache[1] = () => {
                      var _a3;
                      return vue.unref(copy)(((_a3 = vue.unref(currentRoom)) == null ? void 0 : _a3.password) || "");
                    })
                  }, [
                    vue.createVNode(vue.unref(uikitBaseComponentVue3.IconCopy), { class: "copy-icon" }),
                    vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(t)("CurrentRoomInfo.Copy")), 1)
                  ])
                ])) : vue.createCommentVNode("", true),
                vue.createElementVNode("div", _hoisted_15, [
                  vue.createElementVNode("div", _hoisted_16, vue.toDisplayString(vue.unref(t)("CurrentRoomInfo.RoomLink")), 1),
                  vue.createElementVNode("div", _hoisted_17, vue.toDisplayString(roomLink.value), 1),
                  vue.createElementVNode("div", {
                    class: "room-info-copy",
                    onClick: _cache[2] || (_cache[2] = () => vue.unref(copy)(roomLink.value))
                  }, [
                    vue.createVNode(vue.unref(uikitBaseComponentVue3.IconCopy), { class: "copy-icon" }),
                    vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(t)("CurrentRoomInfo.Copy")), 1)
                  ])
                ])
              ])
            ];
          }),
          default: vue.withCtx(() => {
            var _a2, _b;
            return [
              vue.createElementVNode("div", _hoisted_2, [
                vue.createElementVNode("span", _hoisted_3, vue.toDisplayString(((_a2 = vue.unref(currentRoom)) == null ? void 0 : _a2.roomName) || ((_b = vue.unref(currentRoom)) == null ? void 0 : _b.roomId)), 1),
                vue.createVNode(vue.unref(uikitBaseComponentVue3.IconCaretDownSmall), {
                  size: 24,
                  class: "room-title-icon"
                }),
                vue.createElementVNode("span", _hoisted_4, vue.toDisplayString(durationTime.value), 1)
              ])
            ];
          }),
          _: 1
        })
      ])) : vue.createCommentVNode("", true);
    };
  }
});
exports.default = _sfc_main;
