import { currentRoom as _, useUser as R, useRoom as w, computed as x, openBlock as e, createElementBlock as n, unref as o, recreateRoom as C, createCommentVNode as m, rootRoom as $, SEA as g, downloadFile as B, createBaseVNode as s } from "./composables-078fa750.js";
const E = { class: "flex flex-wrap items-center gap-2" }, N = /* @__PURE__ */ s("div", { class: "i-la-tools" }, null, -1), S = /* @__PURE__ */ s("div", { class: "ml-2" }, "Renew", -1), j = [
  N,
  S
], A = /* @__PURE__ */ s("div", { class: "i-la-download" }, null, -1), V = /* @__PURE__ */ s("div", { class: "ml-2" }, "Keys", -1), F = [
  A,
  V
], J = {
  key: 2,
  class: "flex flex-wrap py-4"
}, K = /* @__PURE__ */ s("div", { class: "i-ion-enter-outline" }, null, -1), L = /* @__PURE__ */ s("div", { class: "ml-2" }, "Enter", -1), O = [
  K,
  L
], P = /* @__PURE__ */ s("div", { class: "i-ion-exit-outline" }, null, -1), U = /* @__PURE__ */ s("div", { class: "ml-2" }, "Leave", -1), q = [
  P,
  U
], D = {
  __name: "RoomActions",
  props: {
    pub: { type: String, default: _.pub }
  },
  setup(f) {
    const d = f, { user: i } = R(), { room: l, leaveRoom: h, enterRoom: k } = w(d.pub), a = x(() => d.pub ? d.pub : _.pub);
    async function y(b) {
      var u;
      const t = await g.decrypt(b, i.pair());
      B(JSON.stringify(t), "application/json", `room-${(u = l.profile) == null ? void 0 : u.name}.json`);
    }
    return (b, t) => {
      var u, v;
      return e(), n("div", E, [
        (u = o(l).hosts) != null && u[o(i).pub] ? (e(), n("button", {
          key: 0,
          class: "button",
          onClick: t[0] || (t[0] = (p) => {
            var c, r;
            return o(C)((r = (c = o(l).hosts) == null ? void 0 : c[o(i).pub]) == null ? void 0 : r.enc);
          })
        }, j)) : m("", !0),
        (v = o(l).hosts) != null && v[o(i).pub] ? (e(), n("button", {
          key: 1,
          class: "button",
          onClick: t[1] || (t[1] = (p) => {
            var c, r;
            return y((r = (c = o(l).hosts) == null ? void 0 : c[o(i).pub]) == null ? void 0 : r.enc);
          })
        }, F)) : m("", !0),
        o(a) != o($).pub ? (e(), n("div", J, [
          o(_).pub !== o(a) ? (e(), n("button", {
            key: 0,
            class: "button",
            onClick: t[2] || (t[2] = (p) => o(k)(o(a)))
          }, O)) : (e(), n("button", {
            key: 1,
            class: "button",
            onClick: t[3] || (t[3] = (p) => o(h)())
          }, q))
        ])) : m("", !0)
      ]);
    };
  }
};
export {
  D as default
};
//# sourceMappingURL=RoomActions-714e4680.js.map
