import { defineComponent as $, ref as k, computed as x, createElementBlock as o, createCommentVNode as u, unref as s, openBlock as l, createElementVNode as t, createVNode as c, renderSlot as P, normalizeStyle as N, toDisplayString as q, normalizeClass as T, Transition as _, withCtx as f, TransitionGroup as j, createBlock as A } from "vue";
import { useUser as B, useAuth as E, useClipboard as V, useShare as z, downloadFile as J } from "./composables-BAZQlC3e.js";
import { AuthPass as O, QrShow as Q } from "./components.js";
const D = {
  key: 0,
  class: "flex flex-col items-stretch pb-4 border-1 border-dark-100 border-opacity-10 max-w-120 mx-auto dark-bg-dark-200"
}, F = {
  key: 0,
  class: "flex p-4 items-center bg-dark-100 bg-opacity-20 mt-2 shadow-inset"
}, G = {
  key: 0,
  class: "i-la-lock"
}, K = {
  key: 1,
  class: "i-la-unlock"
}, L = { class: "text-sm" }, R = { class: "flex flex-wrap" }, U = {
  key: 0,
  class: "px-2"
}, Y = {
  key: 1,
  class: "px-2"
}, H = ["href"], I = {
  key: 1,
  class: "flex w-full justify-center mt-4"
}, M = ["value"], se = /* @__PURE__ */ $({
  __name: "AuthCredentials",
  emits: ["close"],
  setup(W, { emit: X }) {
    const n = k("pass"), { user: m } = B();
    function p(r) {
      n.value != r ? n.value = r : n.value = null;
    }
    const { pass: i } = E(), { text: Z, copy: y, copied: b, isSupported: C } = V(), { share: w, isSupported: S } = z(), a = k(!0), v = x(() => {
      var r;
      return a.value ? (r = i == null ? void 0 : i.safe) == null ? void 0 : r.enc : JSON.stringify(m.pair());
    }), g = x(() => a.value ? i.links.pass : i.links.pair);
    return (r, e) => s(m).is ? (l(), o("div", D, [
      e[14] || (e[14] = t("div", { class: "mt-4 mx-6" }, "Please make sure to safely store your cryptographic keypair to be able to use it again later", -1)),
      c(s(O)),
      v.value ? (l(), o("div", F, [
        t("div", {
          class: "flex flex-col w-34 items-center",
          style: N({ color: a.value ? "green" : "red" })
        }, [
          t("button", {
            class: "m-2 button text-2xl",
            onClick: e[0] || (e[0] = (d) => a.value = !a.value)
          }, [
            a.value ? (l(), o("div", G)) : (l(), o("div", K))
          ]),
          t("div", L, q(a.value ? "Encrypted" : "Plain Text"), 1),
          e[7] || (e[7] = t("div", { class: "text-m" }, "Key Pair", -1))
        ], 4),
        t("div", R, [
          s(S) ? (l(), o("button", {
            key: 0,
            class: T(["m-2 button items-center", { active: n.value == "pass" }]),
            onClick: e[1] || (e[1] = (d) => s(w)({ title: "Your key pair", text: v.value }))
          }, e[8] || (e[8] = [
            t("div", { class: "i-la-share" }, null, -1),
            t("div", { class: "px-1" }, "Share", -1)
          ]), 2)) : u("", !0),
          s(C) ? (l(), o("button", {
            key: 1,
            class: "m-2 button items-center",
            onClick: e[2] || (e[2] = (d) => s(y)(v.value))
          }, [
            e[9] || (e[9] = t("div", { class: "i-la-copy" }, null, -1)),
            c(_, { name: "fade" }, {
              default: f(() => [
                s(b) ? (l(), o("div", U, "Copied!")) : (l(), o("div", Y, "Copy"))
              ]),
              _: 1
            })
          ])) : u("", !0),
          t("a", {
            class: "m-2 button items-center",
            href: g.value,
            target: "_blank",
            onClick: e[3] || (e[3] = (d) => p("links"))
          }, e[10] || (e[10] = [
            t("div", { class: "i-la-link" }, null, -1),
            t("div", { class: "px-2" }, "Link", -1)
          ]), 8, H),
          t("button", {
            class: "m-2 button items-center",
            onClick: e[4] || (e[4] = (d) => p("qr"))
          }, e[11] || (e[11] = [
            t("div", { class: "i-la-qrcode" }, null, -1),
            t("div", { class: "px-2" }, "QR", -1)
          ])),
          t("button", {
            class: "m-2 button items-center",
            onClick: e[5] || (e[5] = (d) => p("key"))
          }, e[12] || (e[12] = [
            t("div", { class: "i-la-envelope-open-text" }, null, -1),
            t("div", { class: "px-2" }, "Text", -1)
          ])),
          t("button", {
            class: "m-2 button items-center",
            onClick: e[6] || (e[6] = (d) => {
              s(J)(v.value, "text/json", (s(m).name || "account") + ".json", !1), n.value = null;
            })
          }, e[13] || (e[13] = [
            t("div", { class: "i-la-file-code" }, null, -1),
            t("div", { class: "px-2" }, "JSON", -1)
          ]))
        ])
      ])) : u("", !0),
      n.value ? (l(), o("div", I, [
        c(j, { name: "fade" }, {
          default: f(() => [
            n.value == "key" ? (l(), o("textarea", {
              class: "p-4 text-sm flex-1 rounded-xl",
              key: "text",
              rows: "9",
              value: v.value
            }, null, 8, M)) : u("", !0),
            n.value == "qr" ? (l(), A(s(Q), {
              class: "max-w-600px",
              key: "qr",
              data: a.value ? s(i).links.pass : s(i).links.pair
            }, null, 8, ["data"])) : u("", !0)
          ]),
          _: 1
        })
      ])) : u("", !0),
      P(r.$slots, "default")
    ])) : u("", !0);
  }
});
export {
  se as default
};
//# sourceMappingURL=AuthCredentials-DCOZ4Es4.js.map
