import { defineComponent as c, useUser as p, ref as v, watch as b, openBlock as n, createElementBlock as a, createVNode as i, withCtx as m, createBlock as f, unref as t, createBaseVNode as r, createCommentVNode as k, renderSlot as y, createTextVNode as $, normalizeStyle as w } from "./composables-Ci32s3jE.js";
import { AuthCredentials as C, UiLayer as _, AuthLogin as g, UserPanel as x, UserProfile as B, UserRooms as U } from "./components.js";
const h = { class: "flex flex-col items-center w-full" }, N = /* @__PURE__ */ r("div", { class: "i-la-check" }, null, -1), V = /* @__PURE__ */ r("div", { class: "ml-2" }, "I've stored my key securely", -1), S = [
  N,
  V
], A = {
  key: 1,
  class: "flex flex-col"
}, L = { class: "p-4 flex flex-col items-start" }, H = /* @__PURE__ */ c({
  __name: "UserHome",
  emits: ["user", "room", "close", "chat", "browse"],
  setup(P, { emit: j }) {
    const { user: s } = p();
    function u() {
      s.db.get("safe").get("saved").put(!0);
    }
    const d = v(!1);
    return b(() => s.is, () => {
      s.db.get("safe").get("saved").on((o) => d.value = o);
    }, { immediate: !0 }), (o, e) => (n(), a("div", h, [
      i(t(_), {
        open: t(s).is && !d.value,
        "close-button": "",
        onClose: e[1] || (e[1] = (l) => u())
      }, {
        default: m(() => [
          d.value ? k("", !0) : (n(), f(t(C), { key: 0 }, {
            default: m(() => [
              r("button", {
                class: "button mx-8 justify-center",
                onClick: e[0] || (e[0] = (l) => u())
              }, S)
            ]),
            _: 1
          }))
        ]),
        _: 1
      }, 8, ["open"]),
      t(s).is ? (n(), a("div", A, [
        i(t(x), {
          onBrowse: e[2] || (e[2] = (l) => {
            o.$emit("browse", l), o.$emit("close");
          })
        }),
        r("div", L, [
          i(t(B)),
          i(t(U), {
            onBrowse: e[3] || (e[3] = (l) => o.$emit("room", l))
          })
        ]),
        r("button", {
          class: "p-4 m-4 rounded-xl font-bold text-lg shadow-md",
          style: w({ backgroundColor: t(s).color }),
          onClick: e[4] || (e[4] = (l) => {
            o.$emit("user", t(s).pub), o.$emit("close");
          })
        }, [
          y(o.$slots, "default", {}, () => [
            $(" My public profile")
          ])
        ], 4)
      ])) : (n(), f(t(g), { key: 0 }))
    ]));
  }
});
export {
  H as default
};
//# sourceMappingURL=UserHome-CKHl48X7.js.map
