import { computed as x, createElementBlock as n, openBlock as s, createCommentVNode as b, unref as t, createElementVNode as e } from "vue";
import { currentRoom as v, useUser as C, useRoom as $, recreateRoom as g, rootRoom as E, downloadFile as N } from "./composables-BAZQlC3e.js";
const j = { class: "flex flex-wrap items-center gap-2" }, B = {
  key: 2,
  class: "flex flex-wrap py-4"
}, A = {
  __name: "RoomActions",
  props: {
    pub: { type: String, default: v.pub }
  },
  setup(k) {
    const a = k, { user: l } = C(), { room: u, leaveRoom: y, enterRoom: R } = $(a.pub), m = x(() => a.pub ? a.pub : v.pub);
    async function w(c) {
      var r;
      const o = await l.decrypt(c);
      N(JSON.stringify(o), "application/json", `room-${(r = u.profile) == null ? void 0 : r.name}.json`);
    }
    return (c, o) => {
      var r, f;
      return s(), n("div", j, [
        (r = t(u).hosts) != null && r[t(l).pub] ? (s(), n("button", {
          key: 0,
          class: "button",
          onClick: o[0] || (o[0] = (d) => {
            var i, p;
            return t(g)((p = (i = t(u).hosts) == null ? void 0 : i[t(l).pub]) == null ? void 0 : p.enc);
          })
        }, o[4] || (o[4] = [
          e("div", { class: "i-la-tools" }, null, -1),
          e("div", { class: "ml-2" }, "Renew", -1)
        ]))) : b("", !0),
        (f = t(u).hosts) != null && f[t(l).pub] ? (s(), n("button", {
          key: 1,
          class: "button",
          onClick: o[1] || (o[1] = (d) => {
            var i, p;
            return w((p = (i = t(u).hosts) == null ? void 0 : i[t(l).pub]) == null ? void 0 : p.enc);
          })
        }, o[5] || (o[5] = [
          e("div", { class: "i-la-download" }, null, -1),
          e("div", { class: "ml-2" }, "Keys", -1)
        ]))) : b("", !0),
        m.value != t(E).pub ? (s(), n("div", B, [
          t(v).pub !== m.value ? (s(), n("button", {
            key: 0,
            class: "button",
            onClick: o[2] || (o[2] = (d) => t(R)(m.value))
          }, o[6] || (o[6] = [
            e("div", { class: "i-ion-enter-outline" }, null, -1),
            e("div", { class: "ml-2" }, "Enter", -1)
          ]))) : (s(), n("button", {
            key: 1,
            class: "button",
            onClick: o[3] || (o[3] = (d) => t(y)())
          }, o[7] || (o[7] = [
            e("div", { class: "i-ion-exit-outline" }, null, -1),
            e("div", { class: "ml-2" }, "Leave", -1)
          ])))
        ])) : b("", !0)
      ]);
    };
  }
};
export {
  A as default
};
//# sourceMappingURL=RoomActions-kENR-ICx.js.map
