"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 useCopy = require("../../hooks/useCopy.js");
const utils = require("../../utils/utils.js");
const _hoisted_1 = { class: "room-share" };
const _hoisted_2 = {
  key: 0,
  class: "room-share-empty"
};
const _hoisted_3 = {
  key: 1,
  class: "room-share-content"
};
const _hoisted_4 = { class: "share-item" };
const _hoisted_5 = { class: "share-label" };
const _hoisted_6 = { class: "share-value" };
const _hoisted_7 = {
  key: 0,
  class: "share-item"
};
const _hoisted_8 = { class: "share-label" };
const _hoisted_9 = { class: "share-value" };
const _hoisted_10 = { class: "share-item" };
const _hoisted_11 = { class: "share-label" };
const _hoisted_12 = { class: "share-value" };
const _hoisted_13 = {
  key: 1,
  class: "share-item"
};
const _hoisted_14 = { class: "share-label" };
const _hoisted_15 = { class: "share-value" };
const _hoisted_16 = { class: "share-item" };
const _hoisted_17 = { class: "share-label" };
const _hoisted_18 = { class: "share-value room-link" };
const _hoisted_19 = { class: "room-link-text" };
const _hoisted_20 = { class: "share-actions" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "RoomShare",
  props: {
    roomInfo: {}
  },
  setup(__props) {
    const { t } = uikitBaseComponentVue3.useUIKit();
    const { copy } = useCopy.useCopy();
    const props = __props;
    const formatDateTime = (timestamp) => {
      if (!timestamp) {
        return "--";
      }
      const date = new Date(timestamp * 1e3);
      const year = date.getFullYear();
      const month = (date.getMonth() + 1).toString().padStart(2, "0");
      const day = date.getDate().toString().padStart(2, "0");
      const hours = date.getHours().toString().padStart(2, "0");
      const minutes = date.getMinutes().toString().padStart(2, "0");
      return `${year}-${month}-${day} ${hours}:${minutes}`;
    };
    const roomLink = vue.computed(() => {
      var _a;
      if (!((_a = props.roomInfo) == null ? void 0 : _a.roomId)) {
        return "";
      }
      return utils.generateRoomLink(props.roomInfo.roomId, props.roomInfo.password, props.roomInfo.roomType);
    });
    const copyRoomInfoAndLink = async () => {
      if (!props.roomInfo) {
        uikitBaseComponentVue3.TUIToast.error({ message: t("RoomShare.NoRoomInfo") });
        return;
      }
      const roomInfoLines = [
        `${t("RoomShare.RoomName")}: ${props.roomInfo.roomName}`,
        `${t("RoomShare.RoomId")}: ${props.roomInfo.roomId}`,
        props.roomInfo.password ? `${t("RoomShare.Password")}: ${props.roomInfo.password}` : null,
        props.roomInfo.scheduledStartTime && props.roomInfo.scheduledEndTime ? `${t("RoomShare.RoomTime")}: ${formatDateTime(props.roomInfo.scheduledStartTime)} - ${formatDateTime(props.roomInfo.scheduledEndTime)}` : null,
        `${t("RoomShare.RoomLink")}: ${roomLink.value}`
      ].filter(Boolean);
      const roomInfoText = roomInfoLines.join("\n");
      await copy(roomInfoText);
    };
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        !__props.roomInfo ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, vue.toDisplayString(vue.unref(t)("RoomShare.NoRoomInfo")), 1)) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, [
          vue.createElementVNode("div", _hoisted_4, [
            vue.createElementVNode("div", _hoisted_5, vue.toDisplayString(vue.unref(t)("RoomShare.RoomName")), 1),
            vue.createElementVNode("div", _hoisted_6, vue.toDisplayString(__props.roomInfo.roomName), 1)
          ]),
          __props.roomInfo.scheduledStartTime && __props.roomInfo.scheduledEndTime ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7, [
            vue.createElementVNode("div", _hoisted_8, vue.toDisplayString(vue.unref(t)("RoomShare.RoomTime")), 1),
            vue.createElementVNode("div", _hoisted_9, vue.toDisplayString(formatDateTime(__props.roomInfo.scheduledStartTime)) + " - " + vue.toDisplayString(formatDateTime(__props.roomInfo.scheduledEndTime)), 1)
          ])) : vue.createCommentVNode("", true),
          vue.createElementVNode("div", _hoisted_10, [
            vue.createElementVNode("div", _hoisted_11, vue.toDisplayString(vue.unref(t)("RoomShare.RoomId")), 1),
            vue.createElementVNode("div", _hoisted_12, [
              vue.createTextVNode(vue.toDisplayString(__props.roomInfo.roomId) + " ", 1),
              vue.createVNode(vue.unref(uikitBaseComponentVue3.IconCopy), {
                class: "copy-icon",
                onClick: _cache[0] || (_cache[0] = () => {
                  var _a;
                  return vue.unref(copy)(((_a = __props.roomInfo) == null ? void 0 : _a.roomId) || "");
                })
              })
            ])
          ]),
          __props.roomInfo.password ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_13, [
            vue.createElementVNode("div", _hoisted_14, vue.toDisplayString(vue.unref(t)("RoomShare.Password")), 1),
            vue.createElementVNode("div", _hoisted_15, [
              vue.createTextVNode(vue.toDisplayString(__props.roomInfo.password) + " ", 1),
              vue.createVNode(vue.unref(uikitBaseComponentVue3.IconCopy), {
                class: "copy-icon",
                onClick: _cache[1] || (_cache[1] = () => {
                  var _a;
                  return vue.unref(copy)(((_a = __props.roomInfo) == null ? void 0 : _a.password) || "");
                })
              })
            ])
          ])) : vue.createCommentVNode("", true),
          vue.createElementVNode("div", _hoisted_16, [
            vue.createElementVNode("div", _hoisted_17, vue.toDisplayString(vue.unref(t)("RoomShare.RoomLink")), 1),
            vue.createElementVNode("div", _hoisted_18, [
              vue.createElementVNode("span", _hoisted_19, vue.toDisplayString(roomLink.value), 1),
              vue.createVNode(vue.unref(uikitBaseComponentVue3.IconCopy), {
                class: "copy-icon",
                onClick: _cache[2] || (_cache[2] = () => vue.unref(copy)(roomLink.value))
              })
            ])
          ]),
          vue.createElementVNode("div", _hoisted_20, [
            vue.createVNode(vue.unref(uikitBaseComponentVue3.TUIButton), {
              type: "primary",
              size: "large",
              class: "copy-button",
              onClick: copyRoomInfoAndLink
            }, {
              default: vue.withCtx(() => [
                vue.createTextVNode(vue.toDisplayString(vue.unref(t)("RoomShare.CopyMeetingIdAndLink")), 1)
              ]),
              _: 1
            })
          ])
        ]))
      ]);
    };
  }
});
exports.default = _sfc_main;
