"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 _hoisted_1 = {
  key: 0,
  class: "invitation-container"
};
const _hoisted_2 = { class: "content" };
const _hoisted_3 = { class: "room-info-container" };
const _hoisted_4 = { class: "avatar-wrapper" };
const _hoisted_5 = { class: "invite-text" };
const _hoisted_6 = { class: "room-info" };
const _hoisted_7 = { class: "room-title" };
const _hoisted_8 = { class: "room-details" };
const _hoisted_9 = { class: "detail" };
const _hoisted_10 = { class: "detail" };
const _hoisted_11 = { class: "actions" };
const _hoisted_12 = { class: "reject-button" };
const _hoisted_13 = { class: "reject-button-text" };
const _hoisted_14 = { class: "accept-button" };
const _hoisted_15 = { class: "accept-button-text" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "RoomInvitationH5",
  props: {
    options: {}
  },
  setup(__props) {
    const { t } = uikitBaseComponentVue3.useUIKit();
    const props = __props;
    const visible = vue.ref(false);
    const countdown = vue.ref(0);
    let countdownTimer = null;
    const inviterName = vue.computed(() => props.options.inviterName);
    const inviterAvatar = vue.computed(() => props.options.inviterAvatar);
    const roomName = vue.computed(() => props.options.roomName);
    const hostName = vue.computed(() => props.options.hostName);
    const participantCount = vue.computed(() => props.options.participantCount);
    const duration = vue.computed(() => props.options.duration || 30);
    const hide = () => {
      visible.value = false;
      if (countdownTimer) {
        clearInterval(countdownTimer);
        countdownTimer = null;
      }
    };
    const handleCancel = () => {
      var _a, _b;
      (_b = (_a = props.options).onCancel) == null ? void 0 : _b.call(_a);
      hide();
    };
    const handleAccept = () => {
      var _a, _b;
      (_b = (_a = props.options).onAccept) == null ? void 0 : _b.call(_a);
      hide();
    };
    const handleTimeout = () => {
      var _a, _b;
      (_b = (_a = props.options).onTimeout) == null ? void 0 : _b.call(_a);
      hide();
    };
    const startCountdown = () => {
      countdown.value = duration.value;
      countdownTimer = window.setInterval(() => {
        countdown.value -= 1;
        if (countdown.value <= 0) {
          if (countdownTimer) {
            clearInterval(countdownTimer);
            countdownTimer = null;
          }
          handleTimeout();
        }
      }, 1e3);
    };
    vue.onMounted(() => {
      visible.value = true;
      startCountdown();
    });
    vue.onBeforeUnmount(() => {
      if (countdownTimer) {
        clearInterval(countdownTimer);
      }
    });
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createBlock(vue.Teleport, { to: `#room-invitation-h5-container` }, [
        vue.createVNode(vue.Transition, {
          name: "room-invitation-h5",
          appear: ""
        }, {
          default: vue.withCtx(() => [
            visible.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
              vue.createElementVNode("div", {
                class: "background-blur",
                style: vue.normalizeStyle({ backgroundImage: `url(${inviterAvatar.value})` })
              }, null, 4),
              _cache[1] || (_cache[1] = vue.createElementVNode("div", { class: "background-mask" }, null, -1)),
              vue.createElementVNode("div", _hoisted_2, [
                vue.createElementVNode("div", _hoisted_3, [
                  vue.createElementVNode("div", _hoisted_4, [
                    vue.createVNode(vue.unref(room.Avatar), {
                      src: inviterAvatar.value,
                      size: 60,
                      class: "avatar"
                    }, null, 8, ["src"])
                  ]),
                  vue.createElementVNode("div", _hoisted_5, vue.toDisplayString(vue.unref(t)("RoomInvitation.InviteText", { name: inviterName.value })), 1),
                  vue.createElementVNode("div", _hoisted_6, [
                    vue.createElementVNode("div", _hoisted_7, vue.toDisplayString(roomName.value), 1),
                    vue.createElementVNode("div", _hoisted_8, [
                      vue.createElementVNode("span", _hoisted_9, vue.toDisplayString(vue.unref(t)("RoomInvitation.Host")) + vue.toDisplayString(hostName.value), 1),
                      _cache[0] || (_cache[0] = vue.createElementVNode("span", { class: "divider" }, "|", -1)),
                      vue.createElementVNode("span", _hoisted_10, vue.toDisplayString(vue.unref(t)("RoomInvitation.Participants")) + vue.toDisplayString(participantCount.value) + vue.toDisplayString(vue.unref(t)("RoomInvitation.ParticipantsUnit")), 1)
                    ])
                  ])
                ]),
                vue.createElementVNode("div", _hoisted_11, [
                  vue.createElementVNode("div", {
                    class: "action-item",
                    onClick: handleCancel
                  }, [
                    vue.createElementVNode("span", _hoisted_12, [
                      vue.createVNode(vue.unref(uikitBaseComponentVue3.IconClose), {
                        size: "18",
                        class: "reject-button-icon"
                      })
                    ]),
                    vue.createElementVNode("span", _hoisted_13, vue.toDisplayString(vue.unref(t)("RoomInvitation.NotJoin")), 1)
                  ]),
                  vue.createElementVNode("div", {
                    class: "action-item",
                    onClick: handleAccept
                  }, [
                    vue.createElementVNode("span", _hoisted_14, [
                      vue.createVNode(vue.unref(uikitBaseComponentVue3.IconArrowStrokeUp), {
                        size: "18",
                        class: "accept-button-icon"
                      })
                    ]),
                    vue.createElementVNode("span", _hoisted_15, vue.toDisplayString(vue.unref(t)("RoomInvitation.JoinMeeting")), 1)
                  ])
                ])
              ])
            ])) : vue.createCommentVNode("", true)
          ]),
          _: 1
        })
      ]);
    };
  }
});
exports.default = _sfc_main;
